git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit e7b02af84a46b3c6ce2c5b9340093fa214b9600c

throttle following, recently-update-feeds, subscribed-channels

Matt McKegg committed on 11/2/2016, 12:51:31 AM
Parent: 9ab01d1299a52a303ff09bb2e73ff80739328656

Files changed

modules/obs-following.jschanged
modules/obs-recently-updated-feeds.jschanged
modules/obs-subscribed-channels.jschanged
modules/obs-following.jsView
@@ -3,8 +3,9 @@
33 var MutantPullReduce = require('../lib/mutant-pull-reduce')
44 var plugs = require('patchbay/plugs')
55 var sbot_user_feed = plugs.first(exports.sbot_user_feed = [])
66 var cache = {}
7+var throttle = require('@mmckegg/mutant/throttle')
78
89 exports.obs_following = function (userId) {
910 if (cache[userId]) {
1011 return cache[userId]
@@ -32,12 +33,15 @@
3233 startValue: new Set(),
3334 nextTick: true
3435 })
3536
36- result.has = function (value) {
37- return computed(result, x => x.has(value))
37+ var instance = throttle(result, 2000)
38+ instance.sync = result.sync
39+
40+ instance.has = function (value) {
41+ return computed(instance, x => x.has(value))
3842 }
3943
40- cache[userId] = result
41- return result
44+ cache[userId] = instance
45+ return instance
4246 }
4347 }
modules/obs-recently-updated-feeds.jsView
@@ -3,8 +3,9 @@
33 var computed = require('@mmckegg/mutant/computed')
44 var MutantPullReduce = require('../lib/mutant-pull-reduce')
55 var plugs = require('patchbay/plugs')
66 var sbot_log = plugs.first(exports.sbot_log = [])
7+var throttle = require('@mmckegg/mutant/throttle')
78 var hr = 60 * 60 * 1000
89
910 exports.obs_recently_updated_feeds = function (limit) {
1011 var stream = pull(
@@ -23,10 +24,13 @@
2324 startValue: new Set(),
2425 nextTick: true
2526 })
2627
27- result.has = function (value) {
28- return computed(result, x => x.has(value))
28+ var instance = throttle(result, 2000)
29+ instance.sync = result.sync
30+
31+ instance.has = function (value) {
32+ return computed(instance, x => x.has(value))
2933 }
3034
31- return result
35+ return instance
3236 }
modules/obs-subscribed-channels.jsView
@@ -3,8 +3,9 @@
33 var MutantPullReduce = require('../lib/mutant-pull-reduce')
44 var plugs = require('patchbay/plugs')
55 var sbot_user_feed = plugs.first(exports.sbot_user_feed = [])
66 var cache = {}
7+var throttle = require('@mmckegg/mutant/throttle')
78
89 exports.obs_subscribed_channels = function (userId) {
910 if (cache[userId]) {
1011 return cache[userId]
@@ -35,13 +36,15 @@
3536 startValue: new Set(),
3637 nextTick: true
3738 })
3839
39- result.has = function (value) {
40- return computed(result, x => x.has(value))
40+ var instance = throttle(result, 2000)
41+ instance.sync = result.sync
42+
43+ instance.has = function (value) {
44+ return computed(instance, x => x.has(value))
4145 }
4246
43- cache[userId] = result
44- return result
47+ cache[userId] = instance
48+ return instance
4549 }
46-
4750 }

Built with git-ssb-web