Commit b4df1e66bea6275126d6d9c508356dc44e62b504
implement post(fn)
Dominic Tarr committed on 10/1/2017, 7:54:58 AMParent: 24199ac28da08697028d10aecc22fed647854ce7
Files changed
minimal.js | changed |
minimal.js | |||
---|---|---|---|
@@ -4,8 +4,9 @@ | |||
4 | 4 … | var codec = require('flumecodec/json') | |
5 | 5 … | var AsyncWrite = require('async-write') | |
6 | 6 … | var V = require('ssb-validate') | |
7 | 7 … | var timestamp = require('monotonic-timestamp') | |
8 … | +var Obv = require('obv') | ||
8 | 9 … | ||
9 | 10 … | ||
10 | 11 … | /* | |
11 | 12 … | ## queue (msg, cb) | |
@@ -37,12 +38,16 @@ | |||
37 | 38 … | var state = V.initial(), ready = false | |
38 | 39 … | var waiting = [], flush = [] | |
39 | 40 … | ||
40 | 41 … | var append = db.rawAppend = db.append | |
42 … | + db.post = Obv() | ||
41 | 43 … | var queue = AsyncWrite(function (_, cb) { | |
42 | 44 … | var batch = state.queue//.map(toKeyValueTimestamp) | |
43 | 45 … | state.queue = [] | |
44 | 46 … | append(batch, function (err, v) { | |
47 … | + batch.forEach(function (data) { | ||
48 … | + db.post.set(data) | ||
49 … | + }) | ||
45 | 50 … | cb(err, v) | |
46 | 51 … | }) | |
47 | 52 … | }, function reduce(_, msg) { | |
48 | 53 … | state = V.append(state, msg) |
Built with git-ssb-web