git ssb

1+

Matt McKegg / mutant



Commit bc685ac97855accf26bcdf7168da942ffcdccd1a

watch-throttle: add broadcastInitial option

Matt McKegg committed on 11/19/2016, 11:43:16 AM
Parent: ae401384e63a7c1f60eac488db0787638deb6a7e

Files changed

watch-throttle.jschanged
watch-throttle.jsView
@@ -1,17 +1,22 @@
11 var resolve = require('./resolve')
22 var isObservable = require('./is-observable')
33
4-module.exports = function throttledWatch (obs, minDelay, listener) {
4 +module.exports = function throttledWatch (obs, minDelay, listener, opts) {
55 var throttling = false
66 var lastRefreshAt = 0
77 var lastValueAt = 0
88 var throttleTimer = null
99
10 + var broadcastInitial = !opts || opts.broadcastInitial !== false
11 +
1012 // default delay is 20 ms
1113 minDelay = minDelay || 20
1214
13- listener(resolve(obs))
15 + // run unless opts.broadcastInitial === false
16 + if (broadcastInitial) {
17 + listener(resolve(obs))
18 + }
1419
1520 if (isObservable(obs)) {
1621 return obs(function (v) {
1722 if (!throttling) {

Built with git-ssb-web