mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-09 19:42:48 +00:00
26 lines
587 B
TypeScript
26 lines
587 B
TypeScript
import type { Action } from "svelte/action";
|
|
import { readonly, writable } from "svelte/store";
|
|
|
|
const setCanShare = writable(false);
|
|
export const canShare = readonly(setCanShare);
|
|
|
|
let shareCallback: ((event: Event) => void) | undefined;
|
|
export function triggerShare(event: Event) {
|
|
shareCallback?.(event);
|
|
}
|
|
|
|
export const share: Action<Window, (event: Event) => void> = (
|
|
_node,
|
|
callback: (event: Event) => void,
|
|
) => {
|
|
setCanShare.set(true);
|
|
shareCallback = callback;
|
|
|
|
return {
|
|
destroy() {
|
|
setCanShare.set(false);
|
|
shareCallback = undefined;
|
|
},
|
|
};
|
|
};
|