git ssb

5+

Matt McKegg / ferment



Tree: ce8c9a23510ffcaae086aac41d0d04be17ab0af0

Files: ce8c9a23510ffcaae086aac41d0d04be17ab0af0 / lib / obs-local.js

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

Built with git-ssb-web