This commit is contained in:
2026-09-12 13:59:12 +08:00
commit 941ce4baab
71 changed files with 13037 additions and 0 deletions

21
lib/notify-fanout.js Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
function createSubscribers() {
const clip = new Set();
const fav = new Set();
const theme = new Set();
return {
addClip: (wc) => clip.add(wc),
addFav: (wc) => fav.add(wc),
addTheme: (wc) => theme.add(wc),
drop: (wc) => { clip.delete(wc); fav.delete(wc); theme.delete(wc); },
notifyClip: (ch, payload) => { for (const wc of clip) try { wc.send(ch, payload); } catch {} },
notifyFav: (ch, payload) => { for (const wc of fav) try { wc.send(ch, payload); } catch {} },
notifyTheme: (ch, payload) => { for (const wc of theme) try { wc.send(ch, payload); } catch {} },
get clip() { return clip; },
get fav() { return fav; },
get theme() { return theme; },
};
}
module.exports = { createSubscribers };