diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
| commit | a7cf03c192470cbab13edeb1aec99e0c66dede10 (patch) | |
| tree | 581b4430d1de958dcb666bae80a7678332134602 /src/lib/stores/actions.ts | |
| parent | 010f307346e525ac2e4239a0549d2c1a4d6d102b (diff) | |
Update / use typescript
Diffstat (limited to 'src/lib/stores/actions.ts')
| -rw-r--r-- | src/lib/stores/actions.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/stores/actions.ts b/src/lib/stores/actions.ts new file mode 100644 index 0000000..95702dc --- /dev/null +++ b/src/lib/stores/actions.ts @@ -0,0 +1,41 @@ +import { derived, writable } from 'svelte/store'; +import type { Readable, Writable } from 'svelte/store'; + +export type Actions = { + topic?: TopicAction +}; + +export type TopicAction = { + id: string +}; + +/* + * This is a store to set the actions in the top header. + */ + +const actions: Writable<Actions> = writable({}); + +export const enableTopicActions = (id: string) => { + + actions.update((actionsValue: Actions): Actions => { + + actionsValue.topic = { + id + }; + return actionsValue; + }); +}; + +export const disableTopicActions = () => { + + actions.update((actionsValue): Actions => { + + delete actionsValue.topic; + return actionsValue; + }); +}; + +export const topicActions: Readable<TopicAction> = derived( + actions, + ($actions) => $actions.topic +); |