Commit f72dd7d62b01eb6de4d424c0a1d47a4814ef6599
genericize var names in reusable function
Dominic Tarr committed on 8/14/2017, 12:38:47 PMParent: 89f71075d1cca296946814be2c184d128e17d3d1
Files changed
state/obs.js | changed |
state/obs.js | ||
---|---|---|
@@ -18,12 +18,9 @@ | ||
18 | 18 | |
19 | 19 | exports.create = function (api) { |
20 | 20 | var threadsObs |
21 | 21 | |
22 | - function createStateObs (threadReduce, createStream, opts, initial) { | |
23 | -// var lastTimestamp = initial ? initial.last : Date.now() | |
24 | -// var firstTimestamp = initial ? initial.first || Date.now() : Date.now() | |
25 | - | |
22 | + function createStateObs (reduce, createStream, opts, initial) { | |
26 | 23 | var lastTimestamp = opts.last || Date.now() |
27 | 24 | var firstTimestamp = opts.first || Date.now() |
28 | 25 | |
29 | 26 | function unbox () { |
@@ -35,10 +32,10 @@ | ||
35 | 32 | pull.filter(Boolean) |
36 | 33 | ) |
37 | 34 | } |
38 | 35 | |
39 | - var threadsObs = PullObv( | |
40 | - threadReduce, | |
36 | + var obs = PullObv( | |
37 | + reduce, | |
41 | 38 | pull( |
42 | 39 | Next(function () { |
43 | 40 | return createStream({reverse: true, limit: 500, lt: lastTimestamp}) |
44 | 41 | }), |
@@ -60,13 +57,13 @@ | ||
60 | 57 | }), |
61 | 58 | pull.drain(function (data) { |
62 | 59 | if(data.sync) return |
63 | 60 | firstTimestamp = data.timestamp |
64 | - threadsObs.set(threadReduce(threadsObs.value, data)) | |
61 | + obs.set(reduce(threadsObs.value, data)) | |
65 | 62 | }) |
66 | 63 | ) |
67 | 64 | |
68 | - return threadsObs | |
65 | + return obs | |
69 | 66 | } |
70 | 67 | |
71 | 68 | |
72 | 69 | return nest('state.obs.threads', function buildThreadObs() { |
@@ -106,4 +103,6 @@ | ||
106 | 103 | |
107 | 104 | |
108 | 105 | |
109 | 106 | |
107 | + | |
108 | + |
Built with git-ssb-web