aboutsummaryrefslogtreecommitdiff
path: root/src/stores/actions.js
blob: f7fbc28d953672ba8097fce78d38405427e8b3e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { derived, writable } from 'svelte/store';

/*
 * This is a store to set the actions in the top header.
 */

const actions = writable({});

export const enableTopicActions = (id) => {

  actions.update((actionsValue) => {

    actionsValue.topic = {
      id
    };
    return actionsValue;
  });
};

export const disableTopicActions = () => {

  actions.update((actionsValue) => {

    delete actionsValue.topic;
    return actionsValue;
  });
};

export const topicActions = derived(
  actions,
  ($actions) => $actions.topic
);