Commit a36bb14c1220b36accf4f8fa76de5117992a3ff7
Get pull streams working with inject
Piet Geursen committed on 6/6/2018, 10:45:35 PMParent: ca77c54d481c41a3dbb9f2c43454de9dd9dde4c1
Files changed
lib/inject.js | changed |
package-lock.json | changed |
package.json | changed |
lib/inject.js | ||
---|---|---|
@@ -1,7 +1,8 @@ | ||
1 | 1 … | const { each, map } = require('libnested') |
2 | 2 … | const { onceTrue, watch, Value } = require('mutant') |
3 | 3 … | const assert = require('assert') |
4 … | +const Defer = require('pull-defer').source | |
4 | 5 … | // const Struct = require('../struct') |
5 | 6 … | |
6 | 7 … | // auto-inject the ssb-server to all methods to reduce repitition |
7 | 8 … | module.exports = function inject (server, methods, pluginDeps = []) { |
@@ -33,8 +34,22 @@ | ||
33 | 34 … | ) |
34 | 35 … | } |
35 | 36 … | } |
36 | 37 … | |
38 … | + if (path.includes('pull')) { | |
39 … | + return function () { | |
40 … | + const source = Defer() | |
41 … | + onceTrue( | |
42 … | + server, | |
43 … | + server => { | |
44 … | + var _source = fn(server).apply(null, arguments) | |
45 … | + source.resolve(_source) | |
46 … | + } | |
47 … | + ) | |
48 … | + return source | |
49 … | + } | |
50 … | + } | |
51 … | + | |
37 | 52 … | // NOTE - both `obs` and `sync` methods will return observeables |
38 | 53 … | return function () { |
39 | 54 … | var result = Value({}) |
40 | 55 … | // var result = Struct({}) // WARNING - this shouldn't be copied for other apps, only works with obs.get method here. Probably breaks sync.isBlog |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 194817 bytes New file size: 196200 bytes |
package.json | ||
---|---|---|
@@ -28,8 +28,9 @@ | ||
28 | 28 … | "libnested": "^1.2.1", |
29 | 29 … | "lodash.clonedeep": "^4.5.0", |
30 | 30 … | "mutant": "^3.22.1", |
31 | 31 … | "pull-async": "^1.0.0", |
32 … | + "pull-next-query": "^1.0.0", | |
32 | 33 … | "pull-stream": "^3.6.2", |
33 | 34 … | "ssb-msg-content": "^1.0.1", |
34 | 35 … | "ssb-msg-schemas": "^6.3.0", |
35 | 36 … | "ssb-poll-schema": "^1.6.1", |
Built with git-ssb-web