git ssb

2+

mixmix / ticktack



Commit f72dd7d62b01eb6de4d424c0a1d47a4814ef6599

genericize var names in reusable function

Dominic Tarr committed on 8/14/2017, 12:38:47 PM
Parent: 89f71075d1cca296946814be2c184d128e17d3d1

Files changed

state/obs.jschanged
state/obs.jsView
@@ -18,12 +18,9 @@
1818
1919 exports.create = function (api) {
2020 var threadsObs
2121
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) {
2623 var lastTimestamp = opts.last || Date.now()
2724 var firstTimestamp = opts.first || Date.now()
2825
2926 function unbox () {
@@ -35,10 +32,10 @@
3532 pull.filter(Boolean)
3633 )
3734 }
3835
39- var threadsObs = PullObv(
40- threadReduce,
36+ var obs = PullObv(
37+ reduce,
4138 pull(
4239 Next(function () {
4340 return createStream({reverse: true, limit: 500, lt: lastTimestamp})
4441 }),
@@ -60,13 +57,13 @@
6057 }),
6158 pull.drain(function (data) {
6259 if(data.sync) return
6360 firstTimestamp = data.timestamp
64- threadsObs.set(threadReduce(threadsObs.value, data))
61+ obs.set(reduce(threadsObs.value, data))
6562 })
6663 )
6764
68- return threadsObs
65+ return obs
6966 }
7067
7168
7269 return nest('state.obs.threads', function buildThreadObs() {
@@ -106,4 +103,6 @@
106103
107104
108105
109106
107+
108+

Built with git-ssb-web