@mmckegg/mutant
Advanced tools
Comparing version 3.9.0 to 3.10.0
@@ -22,5 +22,4 @@ var Value = require('./value') | ||
if (opts && opts.nextTick) { | ||
binder.nextTick = true | ||
} | ||
if (opts && opts.idle) binder.idle = true | ||
if (opts && opts.nextTick) binder.nextTick = true | ||
@@ -27,0 +26,0 @@ if (defaultValues && defaultValues.length) { |
@@ -11,2 +11,3 @@ /* A lazy binding take on computed */ | ||
var isSame = require('./lib/is-same') | ||
var onceIdle = require('./once-idle') | ||
@@ -155,5 +156,10 @@ module.exports = computed | ||
onUpdate: function () { | ||
if (this.opts && this.opts.nextTick) { | ||
if (this.opts && this.opts.idle) { | ||
if (!this.updating) { | ||
this.updating = true | ||
onceIdle(this.boundUpdateNow) | ||
} | ||
} else if (this.opts && this.opts.nextTick) { | ||
if (!this.updating) { | ||
this.updating = true | ||
setImmediate(this.boundUpdateNow) | ||
@@ -160,0 +166,0 @@ } |
@@ -22,5 +22,4 @@ var Value = require('./value') | ||
if (opts && opts.nextTick) { | ||
binder.nextTick = true | ||
} | ||
if (opts && opts.nextTick) binder.nextTick = true | ||
if (opts && opts.idle) binder.idle = true | ||
@@ -27,0 +26,0 @@ if (defaultValues) { |
@@ -7,2 +7,4 @@ var applyProperties = require('./lib/apply-properties') | ||
var caches = new global.WeakMap() | ||
var bindQueue = [] | ||
var currentlyBinding = false | ||
var watcher = null | ||
@@ -80,7 +82,19 @@ var invalidateNextTick = require('./lib/invalidate-next-tick') | ||
function maybeBind (node, opts) { | ||
setImmediate(function () { | ||
bindQueue.push([node, opts]) | ||
if (!currentlyBinding) { | ||
currentlyBinding = true | ||
setImmediate(flushBindQueue) | ||
} | ||
} | ||
function flushBindQueue () { | ||
currentlyBinding = false | ||
while (bindQueue.length) { | ||
var item = bindQueue.shift() | ||
var node = item[0] | ||
var opts = item[1] | ||
if (getRootNode(opts.target) === opts.document) { | ||
walk(node, rebind) | ||
} | ||
}) | ||
} | ||
} | ||
@@ -87,0 +101,0 @@ |
@@ -0,1 +1,3 @@ | ||
var onceIdle = require('../once-idle') | ||
module.exports = function (update, onBind, onUnbind) { | ||
@@ -9,2 +11,3 @@ var lazy = false | ||
nextTick: false, | ||
idle: false, | ||
suspended: false, | ||
@@ -35,5 +38,10 @@ update: update, | ||
onUpdate: function () { | ||
if (obj.nextTick) { | ||
if (obj.idle) { | ||
if (!updating) { | ||
updating = true | ||
onceIdle(obj.updateAndBroadcast) | ||
} | ||
} else if (obj.nextTick) { | ||
if (!updating) { | ||
updating = true | ||
setImmediate(obj.updateAndBroadcast) | ||
@@ -40,0 +48,0 @@ } |
10
map.js
@@ -5,2 +5,3 @@ var resolve = require('./resolve') | ||
var addCollectionMethods = require('./lib/add-collection-methods') | ||
var onceIdle = require('./once-idle') | ||
@@ -16,5 +17,4 @@ module.exports = Map | ||
if (opts && opts.nextTick) { | ||
binder.nextTick = true | ||
} | ||
if (opts && opts.nextTick) binder.nextTick = true | ||
if (opts && opts.idle) binder.idle = true | ||
@@ -268,3 +268,5 @@ var itemInvalidators = new global.Map() | ||
function doSoon (fn) { | ||
if (opts.delayTime) { | ||
if (opts.idle) { | ||
onceIdle(fn) | ||
} else if (opts.delayTime) { | ||
setTimeout(fn, opts.delayTime) | ||
@@ -271,0 +273,0 @@ } else { |
{ | ||
"name": "@mmckegg/mutant", | ||
"version": "3.9.0", | ||
"version": "3.10.0", | ||
"description": "Create observables and map them to DOM elements. Massively inspired by hyperscript and observ-*. No virtual dom, just direct observable bindings. Unnecessary garbage collection is avoided by using mutable objects instead of blasting immutable junk all over the place.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -13,5 +13,4 @@ var LazyWatcher = require('./lib/lazy-watcher') | ||
if (opts && opts.nextTick) { | ||
binder.nextTick = true | ||
} | ||
if (opts && opts.nextTick) binder.nextTick = true | ||
if (opts && opts.idle) binder.idle = true | ||
@@ -18,0 +17,0 @@ var observable = function MutantProxyCollection (listener) { |
@@ -13,5 +13,4 @@ var LazyWatcher = require('./lib/lazy-watcher') | ||
if (opts && opts.nextTick) { | ||
binder.nextTick = true | ||
} | ||
if (opts && opts.nextTick) binder.nextTick = true | ||
if (opts && opts.idle) binder.idle = true | ||
@@ -18,0 +17,0 @@ var observable = function MutantProxyDict (listener) { |
@@ -13,5 +13,4 @@ var LazyWatcher = require('./lib/lazy-watcher') | ||
if (opts && opts.nextTick) { | ||
binder.nextTick = true | ||
} | ||
if (opts && opts.nextTick) binder.nextTick = true | ||
if (opts && opts.idle) binder.idle = true | ||
@@ -18,0 +17,0 @@ var observable = function MutantProxy (listener) { |
@@ -27,5 +27,4 @@ var LazyWatcher = require('./lib/lazy-watcher') | ||
if (opts && opts.nextTick) { | ||
self.binder.nextTick = true | ||
} | ||
if (opts && opts.nextTick) self.binder.nextTick = true | ||
if (opts && opts.idle) self.binder.idle = true | ||
@@ -32,0 +31,0 @@ if (defaultValues && defaultValues.length) { |
@@ -19,5 +19,4 @@ var Value = require('./value') | ||
if (opts && opts.nextTick) { | ||
binder.nextTick = true | ||
} | ||
if (opts && opts.nextTick) binder.nextTick = true | ||
if (opts && opts.idle) binder.idle = true | ||
@@ -24,0 +23,0 @@ var comparer = opts && opts.comparer || null |
var resolve = require('./resolve') | ||
var isObservable = require('./is-observable') | ||
var onceIdle = require('./once-idle') | ||
@@ -22,5 +23,10 @@ module.exports = watchAll | ||
function broadcast () { | ||
if (opts && opts.nextTick) { | ||
if (opts && opts.idle) { | ||
if (!broadcasting) { | ||
broadcasting = true | ||
onceIdle(broadcastNow) | ||
} | ||
} else if (opts && opts.nextTick) { | ||
if (!broadcasting) { | ||
broadcasting = true | ||
setImmediate(broadcastNow) | ||
@@ -27,0 +33,0 @@ } |
80338
50
2589