aboutsummaryrefslogtreecommitdiff
path: root/src/stores/actions.js
blob: ae0190624c751017923a92d9c6ae37364173a28c (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.
 */

export 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
);