]>
git.r.bdr.sh - rbdr/forum/blob - src/stores/forums.js
e7acb606cf536db7f227018da308eff532a3136f
1 import { readable
} from 'svelte/store';
7 kChangeFeedEventName: 'changefeed:forums',
9 // The exported data structure
13 // Handles messages from the event
15 handleChangeFeed(data
) {
17 // No old value == add
19 return internals
.forums
.push(data
.new_val
);
22 // We have an old value, let's find it.
23 const index
= internals
.forums
.findIndex((element
) => element
.id
=== data
.old_val
.id
);
27 return internals
.forums
.splice(index
, 1, data
.new_val
|| undefined);
30 return internals
.forums
.splice(index
, 1);
35 export const forums
= readable(internals
.forums
, (set) => {