git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 0df7b2e9903705c4b2201aa29a6a6c1560b102af

Files: 0df7b2e9903705c4b2201aa29a6a6c1560b102af / modules / obs-local.js

574 bytesRaw
1var MutantSet = require('@mmckegg/mutant/set')
2var plugs = require('patchbay/plugs')
3var sbot_list_local = plugs.first(exports.sbot_list_local = [])
4
5var cache = null
6
7exports.obs_local = function () {
8 if (cache) {
9 return cache
10 } else {
11 var result = MutantSet([], {nextTick: true})
12 // todo: make this clean up on unlisten
13
14 refresh()
15 setInterval(refresh, 10e3)
16
17 cache = result
18 return result
19 }
20
21 // scope
22
23 function refresh () {
24 sbot_list_local((err, keys) => {
25 if (err) throw console.log(err)
26 result.set(keys)
27 })
28 }
29}
30

Built with git-ssb-web