git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 4fefa6f1c65b8021e6ca1d82bcf83298da1ae22a

Files: 4fefa6f1c65b8021e6ca1d82bcf83298da1ae22a / lib / mutant-to-pull.js

427 bytesRaw
1var watch = require('mutant/watch')
2var pushable = require('pull-pushable')
3
4module.exports = function (obs) {
5 var releases = []
6
7 // create listener with `onClose` handler
8 var listener = pushable(function onClose () {
9 // if listener is found, delete from list
10 while (releases.length) {
11 releases.pop()()
12 }
13 })
14
15 releases.push(watch(obs, (value) => {
16 listener.push(value)
17 }))
18
19 return listener
20}
21

Built with git-ssb-web