git ssb

0+

Josiah / scuttle-tag



Tree: f8ac0ce23d5685c236e76ded42ded5572d52f53f

Files: f8ac0ce23d5685c236e76ded42ded5572d52f53f / tag / pull / find.js

757 bytesRaw
1const nest = require('depnest')
2const defer = require('pull-defer')
3const pull = require('pull-stream')
4const onceTrue = require('mutant/once-true')
5
6exports.gives = nest('tag.pull.find')
7
8exports.needs = nest({
9 'sbot.obs.connection': 'first'
10})
11
12exports.create = function(api) {
13 return nest({ 'tag.pull.find': find })
14
15 function find(opts) {
16 return StreamWhenConnected(api.sbot.obs.connection, (sbot) => {
17 if (!sbot.tags || !sbot.tags.stream) return pull.empty()
18 return sbot.tags.stream(opts)
19 })
20 }
21}
22
23// COPIED from patchcore 'feed.pull.private'
24function StreamWhenConnected (connection, fn) {
25 var stream = defer.source()
26 onceTrue(connection, function (connection) {
27 stream.resolve(fn(connection))
28 })
29 return stream
30}
31

Built with git-ssb-web