Comparing version 0.0.5 to 0.0.6
@@ -16,8 +16,4 @@ import { createRuntime } from 'babel-plugin-jsx-dom-expressions'; | ||
context: null, | ||
frozen: false, | ||
queues: { | ||
immediate: { | ||
tasks: [], | ||
nextIndex: 0, | ||
nextHandle: 1 | ||
}, | ||
deferred: { | ||
@@ -30,5 +26,17 @@ tasks: [], | ||
clock: 0, | ||
queueTask: function(task, defer) { | ||
queueTask: function(task, value) { | ||
var q; | ||
if (defer) { | ||
if (Core.frozen) { | ||
if (task.handle != null) { | ||
Core.cancelTask(task.handle); | ||
} | ||
Core.queues.current.tasks.push(task); | ||
task.value = value; | ||
task.handle = Core.queues.current.nextHandle++; | ||
return; | ||
} | ||
if (task.defer) { | ||
if (task.dhandle != null) { | ||
Core.cancelTask(task.dhandle, task.defer); | ||
} | ||
q = Core.queues.deferred; | ||
@@ -42,10 +50,11 @@ if (!q.tasks.length) { | ||
q.tasks.push(task); | ||
return q.nextHandle++; | ||
task.value = value; | ||
task.dhandle = q.nextHandle++; | ||
return; | ||
} | ||
Core.queues.immediate.tasks.push(task); | ||
return Core.queues.immediate.nextHandle++; | ||
task(value); | ||
}, | ||
cancelTask: function(handle, defer) { | ||
var index, q; | ||
q = defer ? Core.queues.deferred : Core.queues.immediate; | ||
q = defer ? Core.queues.deferred : Core.queues.current; | ||
index = handle - (q.nextHandle - q.tasks.length); | ||
@@ -56,3 +65,3 @@ if (q.nextIndex <= index) { | ||
}, | ||
processUpdates: function(q) { | ||
processUpdates: function(q, current) { | ||
var count, err, mark, task; | ||
@@ -66,2 +75,8 @@ count = 0; | ||
} | ||
if (current && task.defer) { | ||
task.handle = void 0; | ||
Core.queueTask(task, task.value); | ||
q.nextIndex++; | ||
continue; | ||
} | ||
if (q.nextIndex > mark) { | ||
@@ -77,4 +92,3 @@ if (count++ > 5000) { | ||
task(task.value); | ||
task.handle = null; | ||
task.value = null; | ||
task.handle = task.dhandle = task.value = void 0; | ||
} catch (error) { | ||
@@ -90,7 +104,18 @@ err = error; | ||
run: function(fn) { | ||
var execute; | ||
execute = !Core.queues.immediate.tasks.length; | ||
var execute, prevQueue; | ||
if (!Core.frozen) { | ||
execute = true; | ||
prevQueue = Core.queues.current; | ||
Core.queues.current = { | ||
tasks: [], | ||
nextIndex: 0, | ||
nextHandle: 1 | ||
}; | ||
Core.frozen = true; | ||
} | ||
fn(); | ||
if (execute) { | ||
return Core.processUpdates(Core.queues.immediate); | ||
Core.frozen = false; | ||
Core.processUpdates(Core.queues.current, true); | ||
Core.queues.current = prevQueue; | ||
} | ||
@@ -323,3 +348,3 @@ }, | ||
var d; | ||
d = this._subscribe(arguments); | ||
d = this._subscribe.apply(this, arguments); | ||
(observer.next || observer)(this.__value); | ||
@@ -348,19 +373,17 @@ return d; | ||
notify(type, value) { | ||
if (!this.__subscriptions.size) { | ||
var handler, i, ref, size, sub; | ||
if (!(size = this.__subscriptions.size)) { | ||
return; | ||
} | ||
return Core$1.run(() => { | ||
var handler, ref, sub; | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
if (!(handler = sub[type])) { | ||
continue; | ||
} | ||
if (handler.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
handler.value = value; | ||
handler.handle = Core$1.queueTask(handler, handler.defer); | ||
i = 0; | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
if (!(handler = sub[type])) { | ||
continue; | ||
} | ||
}); | ||
Core$1.queueTask(handler, value); | ||
if (++i === size) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -457,17 +480,6 @@ | ||
subscribe(observer) { | ||
var d, oldSize; | ||
oldSize = this.__subscriptions.size; | ||
d = this._subscribe(arguments); | ||
if (!oldSize) { | ||
return d; | ||
} | ||
(observer.next || observer)(this.__value); | ||
return d; | ||
} | ||
_subscribe(fn) { | ||
_subscribe() { | ||
var disposable, oldSize; | ||
oldSize = this.__subscriptions.size; | ||
disposable = super._subscribe(fn); | ||
disposable = super._subscribe.apply(this, arguments); | ||
if (!oldSize && this.__subscriptions.size && !this.context.disposables.length) { | ||
@@ -482,8 +494,11 @@ this._skipNotify = true; | ||
unsubscribe(fn) { | ||
var delayed; | ||
super.unsubscribe(fn); | ||
return Core$1.queueTask(() => { | ||
delayed = () => { | ||
if (!this.__subscriptions.size) { | ||
return this.clean(); | ||
} | ||
}, true); | ||
}; | ||
delayed.defer = true; | ||
return Core$1.queueTask(delayed); | ||
} | ||
@@ -565,3 +580,3 @@ | ||
// non-arrays | ||
newListUnwrapped = (newList != null ? newList._state : void 0) || newList; | ||
newListUnwrapped = Core$1.unwrap(newList, true); | ||
if (!Array.isArray(newListUnwrapped)) { | ||
@@ -664,3 +679,3 @@ if ((newListUnwrapped == null) || newListUnwrapped === false) { | ||
mapped[j] = newMapped[j]; | ||
disposables[i] = tempDisposables[i]; | ||
disposables[j] = tempDisposables[j]; | ||
} else { | ||
@@ -748,16 +763,10 @@ mapped[j] = Core$1.root(function(dispose) { | ||
notify(value) { | ||
var ref, sub; | ||
if (!this.__subscriptions.size) { | ||
return; | ||
} | ||
return Core$1.run(() => { | ||
var ref, sub; | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
if (sub.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
sub.value = value; | ||
sub.handle = Core$1.queueTask(sub, sub.defer); | ||
} | ||
}); | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
Core$1.queueTask(sub, value); | ||
} | ||
} | ||
@@ -801,15 +810,8 @@ | ||
trigger: function(property, value, notify) { | ||
var subs; | ||
var sub, subs; | ||
subs = this._child_subscriptions[property]; | ||
if (subs != null ? subs.size : void 0) { | ||
Core$1.run(function() { | ||
var sub; | ||
for (sub of subs) { | ||
if (sub.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
sub.value = value; | ||
sub.handle = Core$1.queueTask(sub, sub.defer); | ||
} | ||
}); | ||
for (sub of subs) { | ||
Core$1.queueTask(sub, value); | ||
} | ||
} | ||
@@ -911,26 +913,38 @@ if (notify) { | ||
set() { | ||
var changes, current, i, property, ref, ref1, temp, value; | ||
var args, ref; | ||
if ((ref = Core$1.context) != null ? ref.pure : void 0) { | ||
return console.log('Cannot update in a Selector'); | ||
} | ||
if (arguments.length === 1) { | ||
ref1 = arguments[0]; | ||
for (property in ref1) { | ||
value = ref1[property]; | ||
this._setProperty(property, value); | ||
args = arguments; | ||
Core$1.run(() => { | ||
var change, changes, current, i, j, len, property, ref1, ref2, temp, value; | ||
if (args.length === 1) { | ||
if (Array.isArray(args[0])) { | ||
ref1 = args[0]; | ||
for (j = 0, len = ref1.length; j < len; j++) { | ||
change = ref1[j]; | ||
this.set.apply(this, change); | ||
} | ||
} else { | ||
ref2 = args[0]; | ||
for (property in ref2) { | ||
value = ref2[property]; | ||
this._setProperty(property, value); | ||
} | ||
} | ||
return; | ||
} | ||
return; | ||
} | ||
current = this._state; | ||
changes = arguments[arguments.length - 1]; | ||
i = 0; | ||
while (i < arguments.length - 1 && ((temp = current[arguments[i]]) != null)) { | ||
current = temp; | ||
i++; | ||
} | ||
setNested(current, changes); | ||
current = this._state; | ||
changes = args[args.length - 1]; | ||
i = 0; | ||
while (i < args.length - 1 && ((temp = current[args[i]]) != null)) { | ||
current = temp; | ||
i++; | ||
} | ||
return setNested(current, changes); | ||
}); | ||
} | ||
replace() { | ||
var change, current, i, j, len, property, ref, temp, value; | ||
var changes, current, i, property, temp, value; | ||
if (arguments.length === 1) { | ||
@@ -940,8 +954,13 @@ if (!(arguments[0] instanceof Object)) { | ||
} | ||
ref = Core$1.diff(arguments[0], this._state); | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
change = ref[j]; | ||
this.replace(change); | ||
} | ||
return; | ||
changes = arguments[0]; | ||
Core$1.run(() => { | ||
var change, j, len; | ||
if (!Array.isArray(changes)) { | ||
changes = Core$1.diff(changes, this._state); | ||
} | ||
for (j = 0, len = changes.length; j < len; j++) { | ||
change = changes[j]; | ||
this.replace.apply(this, change); | ||
} | ||
}); | ||
} | ||
@@ -970,4 +989,4 @@ if (arguments.length === 2) { | ||
this._disposables.push(selector.subscribe((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -981,7 +1000,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
})); | ||
@@ -992,4 +1007,4 @@ continue; | ||
selection.then((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -1003,7 +1018,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
}); | ||
@@ -1021,17 +1032,7 @@ continue; | ||
return selector.then((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
}); | ||
} | ||
return this._disposables.push(selector.subscribe((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
})); | ||
@@ -1255,54 +1256,66 @@ })(key, selector); | ||
set() { | ||
var changes, j, k, len, notify, path, property, ref, ref1, ref2, state, subKeys, subPaths, subs, value; | ||
var args, ref; | ||
if ((ref = Core$1.context) != null ? ref.pure : void 0) { | ||
return console.log('Cannot update in a Selector'); | ||
} | ||
if (arguments.length === 1) { | ||
ref1 = arguments[0]; | ||
for (property in ref1) { | ||
value = ref1[property]; | ||
this._setProperty(property, value); | ||
args = arguments; | ||
return Core$1.run(() => { | ||
var change, changes, j, k, l, len, len1, notify, path, property, ref1, ref2, ref3, state, subKeys, subPaths, subs, value; | ||
if (args.length === 1) { | ||
if (Array.isArray(args[0])) { | ||
ref1 = args[0]; | ||
for (j = 0, len = ref1.length; j < len; j++) { | ||
change = ref1[j]; | ||
this.set.apply(this, change); | ||
} | ||
} else { | ||
ref2 = args[0]; | ||
for (property in ref2) { | ||
value = ref2[property]; | ||
this._setProperty(property, value); | ||
} | ||
} | ||
return; | ||
} | ||
return; | ||
} | ||
changes = arguments[arguments.length - 1]; | ||
({state, subs, subPaths} = this._resolvePath(arguments, arguments.length - 1)); | ||
if (!state) { | ||
return; | ||
} | ||
notify = Array.isArray(state); | ||
for (property in changes) { | ||
value = changes[property]; | ||
notify = notify || !(indexOf.call(state, property) >= 0); | ||
if (value === void 0) { | ||
delete state[property]; | ||
} else { | ||
state[property] = value; | ||
changes = args[args.length - 1]; | ||
({state, subs, subPaths} = this._resolvePath(args, args.length - 1)); | ||
if (!state) { | ||
return; | ||
} | ||
if (subs) { | ||
this.trigger(subs != null ? (ref2 = subs[property]) != null ? ref2._subs : void 0 : void 0, value); | ||
notify = Array.isArray(state); | ||
for (property in changes) { | ||
value = changes[property]; | ||
notify = notify || !(indexOf.call(state, property) >= 0); | ||
if (value === void 0) { | ||
delete state[property]; | ||
} else { | ||
state[property] = value; | ||
} | ||
if (subs) { | ||
this.trigger(subs != null ? (ref3 = subs[property]) != null ? ref3._subs : void 0 : void 0, value); | ||
} | ||
} | ||
} | ||
if (notify) { | ||
this.trigger(subs != null ? subs._subs : void 0, state); | ||
} | ||
for (j = 0, len = subPaths.length; j < len; j++) { | ||
path = subPaths[j]; | ||
this.trigger(path.subs, path.state); | ||
} | ||
// prune subs | ||
if (value === void 0) { | ||
delete subs[property]; | ||
} else if (Array.isArray(value) && !value.length) { | ||
subKeys = ['_subs', 'clock', '_subPath']; | ||
for (k in subs[property]) { | ||
if (!(indexOf.call(subKeys, k) >= 0)) { | ||
delete subs[property][k]; | ||
if (notify) { | ||
this.trigger(subs != null ? subs._subs : void 0, state); | ||
} | ||
for (l = 0, len1 = subPaths.length; l < len1; l++) { | ||
path = subPaths[l]; | ||
this.trigger(path.subs, path.state); | ||
} | ||
// prune subs | ||
if (value === void 0) { | ||
delete subs[property]; | ||
} else if (Array.isArray(value) && !value.length) { | ||
subKeys = ['_subs', 'clock', '_subPath']; | ||
for (k in subs[property]) { | ||
if (!(indexOf.call(subKeys, k) >= 0)) { | ||
delete subs[property][k]; | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
replace() { | ||
var change, j, l, len, len1, notify, path, property, ref, ref1, state, subPaths, subs, value; | ||
var changes, j, len, notify, path, property, ref, state, subPaths, subs, value; | ||
if (arguments.length === 1) { | ||
@@ -1312,7 +1325,13 @@ if (!(arguments[0] instanceof Object)) { | ||
} | ||
ref = Core$1.diff(arguments[0], this._state); | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
change = ref[j]; | ||
this.replace(change); | ||
} | ||
changes = arguments[0]; | ||
Core$1.run(() => { | ||
var change, j, len; | ||
if (!Array.isArray(changes)) { | ||
changes = Core$1.diff(changes, this._state); | ||
} | ||
for (j = 0, len = changes.length; j < len; j++) { | ||
change = changes[j]; | ||
this.replace.apply(this, change); | ||
} | ||
}); | ||
return; | ||
@@ -1342,3 +1361,3 @@ } | ||
if (subs) { | ||
this.trigger((ref1 = subs[property]) != null ? ref1._subs : void 0, value); | ||
this.trigger((ref = subs[property]) != null ? ref._subs : void 0, value); | ||
} | ||
@@ -1348,4 +1367,4 @@ if (notify) { | ||
} | ||
for (l = 0, len1 = subPaths.length; l < len1; l++) { | ||
path = subPaths[l]; | ||
for (j = 0, len = subPaths.length; j < len; j++) { | ||
path = subPaths[j]; | ||
this.trigger(path.subs, path.state); | ||
@@ -1362,4 +1381,4 @@ } | ||
this._disposables.push(selector.subscribe((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -1373,7 +1392,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
})); | ||
@@ -1384,4 +1399,4 @@ continue; | ||
selection.then((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -1395,7 +1410,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
}); | ||
@@ -1413,17 +1424,7 @@ continue; | ||
return selector.then((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
}); | ||
} | ||
return this._disposables.push(selector.subscribe((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
})); | ||
@@ -1450,15 +1451,9 @@ })(key, selector); | ||
trigger(subs, value) { | ||
var sub; | ||
if (!(subs != null ? subs.size : void 0)) { | ||
return; | ||
} | ||
return Core$1.run(function() { | ||
var sub; | ||
for (sub of subs) { | ||
if (sub.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
sub.value = value; | ||
sub.handle = Core$1.queueTask(sub, sub.defer); | ||
} | ||
}); | ||
for (sub of subs) { | ||
Core$1.queueTask(sub, value); | ||
} | ||
} | ||
@@ -1465,0 +1460,0 @@ |
@@ -17,2 +17,4 @@ # Data Types | ||
Alternatively if you can do multiple sets in a single call by passing an array of paths and changes. | ||
### replace(...path, value) | ||
@@ -22,2 +24,4 @@ | ||
Alternatively if you can do multiple replaces in a single call by passing an array of paths and values. | ||
### select(...(object|fn)) | ||
@@ -24,0 +28,0 @@ |
405
lib/solid.js
@@ -20,8 +20,4 @@ 'use strict'; | ||
context: null, | ||
frozen: false, | ||
queues: { | ||
immediate: { | ||
tasks: [], | ||
nextIndex: 0, | ||
nextHandle: 1 | ||
}, | ||
deferred: { | ||
@@ -34,5 +30,17 @@ tasks: [], | ||
clock: 0, | ||
queueTask: function(task, defer) { | ||
queueTask: function(task, value) { | ||
var q; | ||
if (defer) { | ||
if (Core.frozen) { | ||
if (task.handle != null) { | ||
Core.cancelTask(task.handle); | ||
} | ||
Core.queues.current.tasks.push(task); | ||
task.value = value; | ||
task.handle = Core.queues.current.nextHandle++; | ||
return; | ||
} | ||
if (task.defer) { | ||
if (task.dhandle != null) { | ||
Core.cancelTask(task.dhandle, task.defer); | ||
} | ||
q = Core.queues.deferred; | ||
@@ -46,10 +54,11 @@ if (!q.tasks.length) { | ||
q.tasks.push(task); | ||
return q.nextHandle++; | ||
task.value = value; | ||
task.dhandle = q.nextHandle++; | ||
return; | ||
} | ||
Core.queues.immediate.tasks.push(task); | ||
return Core.queues.immediate.nextHandle++; | ||
task(value); | ||
}, | ||
cancelTask: function(handle, defer) { | ||
var index, q; | ||
q = defer ? Core.queues.deferred : Core.queues.immediate; | ||
q = defer ? Core.queues.deferred : Core.queues.current; | ||
index = handle - (q.nextHandle - q.tasks.length); | ||
@@ -60,3 +69,3 @@ if (q.nextIndex <= index) { | ||
}, | ||
processUpdates: function(q) { | ||
processUpdates: function(q, current) { | ||
var count, err, mark, task; | ||
@@ -70,2 +79,8 @@ count = 0; | ||
} | ||
if (current && task.defer) { | ||
task.handle = void 0; | ||
Core.queueTask(task, task.value); | ||
q.nextIndex++; | ||
continue; | ||
} | ||
if (q.nextIndex > mark) { | ||
@@ -81,4 +96,3 @@ if (count++ > 5000) { | ||
task(task.value); | ||
task.handle = null; | ||
task.value = null; | ||
task.handle = task.dhandle = task.value = void 0; | ||
} catch (error) { | ||
@@ -94,7 +108,18 @@ err = error; | ||
run: function(fn) { | ||
var execute; | ||
execute = !Core.queues.immediate.tasks.length; | ||
var execute, prevQueue; | ||
if (!Core.frozen) { | ||
execute = true; | ||
prevQueue = Core.queues.current; | ||
Core.queues.current = { | ||
tasks: [], | ||
nextIndex: 0, | ||
nextHandle: 1 | ||
}; | ||
Core.frozen = true; | ||
} | ||
fn(); | ||
if (execute) { | ||
return Core.processUpdates(Core.queues.immediate); | ||
Core.frozen = false; | ||
Core.processUpdates(Core.queues.current, true); | ||
Core.queues.current = prevQueue; | ||
} | ||
@@ -327,3 +352,3 @@ }, | ||
var d; | ||
d = this._subscribe(arguments); | ||
d = this._subscribe.apply(this, arguments); | ||
(observer.next || observer)(this.__value); | ||
@@ -352,19 +377,17 @@ return d; | ||
notify(type, value) { | ||
if (!this.__subscriptions.size) { | ||
var handler, i, ref, size, sub; | ||
if (!(size = this.__subscriptions.size)) { | ||
return; | ||
} | ||
return Core$1.run(() => { | ||
var handler, ref, sub; | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
if (!(handler = sub[type])) { | ||
continue; | ||
} | ||
if (handler.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
handler.value = value; | ||
handler.handle = Core$1.queueTask(handler, handler.defer); | ||
i = 0; | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
if (!(handler = sub[type])) { | ||
continue; | ||
} | ||
}); | ||
Core$1.queueTask(handler, value); | ||
if (++i === size) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -461,17 +484,6 @@ | ||
subscribe(observer) { | ||
var d, oldSize; | ||
oldSize = this.__subscriptions.size; | ||
d = this._subscribe(arguments); | ||
if (!oldSize) { | ||
return d; | ||
} | ||
(observer.next || observer)(this.__value); | ||
return d; | ||
} | ||
_subscribe(fn) { | ||
_subscribe() { | ||
var disposable, oldSize; | ||
oldSize = this.__subscriptions.size; | ||
disposable = super._subscribe(fn); | ||
disposable = super._subscribe.apply(this, arguments); | ||
if (!oldSize && this.__subscriptions.size && !this.context.disposables.length) { | ||
@@ -486,8 +498,11 @@ this._skipNotify = true; | ||
unsubscribe(fn) { | ||
var delayed; | ||
super.unsubscribe(fn); | ||
return Core$1.queueTask(() => { | ||
delayed = () => { | ||
if (!this.__subscriptions.size) { | ||
return this.clean(); | ||
} | ||
}, true); | ||
}; | ||
delayed.defer = true; | ||
return Core$1.queueTask(delayed); | ||
} | ||
@@ -569,3 +584,3 @@ | ||
// non-arrays | ||
newListUnwrapped = (newList != null ? newList._state : void 0) || newList; | ||
newListUnwrapped = Core$1.unwrap(newList, true); | ||
if (!Array.isArray(newListUnwrapped)) { | ||
@@ -668,3 +683,3 @@ if ((newListUnwrapped == null) || newListUnwrapped === false) { | ||
mapped[j] = newMapped[j]; | ||
disposables[i] = tempDisposables[i]; | ||
disposables[j] = tempDisposables[j]; | ||
} else { | ||
@@ -752,16 +767,10 @@ mapped[j] = Core$1.root(function(dispose) { | ||
notify(value) { | ||
var ref, sub; | ||
if (!this.__subscriptions.size) { | ||
return; | ||
} | ||
return Core$1.run(() => { | ||
var ref, sub; | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
if (sub.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
sub.value = value; | ||
sub.handle = Core$1.queueTask(sub, sub.defer); | ||
} | ||
}); | ||
ref = this.__subscriptions; | ||
for (sub of ref) { | ||
Core$1.queueTask(sub, value); | ||
} | ||
} | ||
@@ -805,15 +814,8 @@ | ||
trigger: function(property, value, notify) { | ||
var subs; | ||
var sub, subs; | ||
subs = this._child_subscriptions[property]; | ||
if (subs != null ? subs.size : void 0) { | ||
Core$1.run(function() { | ||
var sub; | ||
for (sub of subs) { | ||
if (sub.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
sub.value = value; | ||
sub.handle = Core$1.queueTask(sub, sub.defer); | ||
} | ||
}); | ||
for (sub of subs) { | ||
Core$1.queueTask(sub, value); | ||
} | ||
} | ||
@@ -915,26 +917,38 @@ if (notify) { | ||
set() { | ||
var changes, current, i, property, ref, ref1, temp, value; | ||
var args, ref; | ||
if ((ref = Core$1.context) != null ? ref.pure : void 0) { | ||
return console.log('Cannot update in a Selector'); | ||
} | ||
if (arguments.length === 1) { | ||
ref1 = arguments[0]; | ||
for (property in ref1) { | ||
value = ref1[property]; | ||
this._setProperty(property, value); | ||
args = arguments; | ||
Core$1.run(() => { | ||
var change, changes, current, i, j, len, property, ref1, ref2, temp, value; | ||
if (args.length === 1) { | ||
if (Array.isArray(args[0])) { | ||
ref1 = args[0]; | ||
for (j = 0, len = ref1.length; j < len; j++) { | ||
change = ref1[j]; | ||
this.set.apply(this, change); | ||
} | ||
} else { | ||
ref2 = args[0]; | ||
for (property in ref2) { | ||
value = ref2[property]; | ||
this._setProperty(property, value); | ||
} | ||
} | ||
return; | ||
} | ||
return; | ||
} | ||
current = this._state; | ||
changes = arguments[arguments.length - 1]; | ||
i = 0; | ||
while (i < arguments.length - 1 && ((temp = current[arguments[i]]) != null)) { | ||
current = temp; | ||
i++; | ||
} | ||
setNested(current, changes); | ||
current = this._state; | ||
changes = args[args.length - 1]; | ||
i = 0; | ||
while (i < args.length - 1 && ((temp = current[args[i]]) != null)) { | ||
current = temp; | ||
i++; | ||
} | ||
return setNested(current, changes); | ||
}); | ||
} | ||
replace() { | ||
var change, current, i, j, len, property, ref, temp, value; | ||
var changes, current, i, property, temp, value; | ||
if (arguments.length === 1) { | ||
@@ -944,8 +958,13 @@ if (!(arguments[0] instanceof Object)) { | ||
} | ||
ref = Core$1.diff(arguments[0], this._state); | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
change = ref[j]; | ||
this.replace(change); | ||
} | ||
return; | ||
changes = arguments[0]; | ||
Core$1.run(() => { | ||
var change, j, len; | ||
if (!Array.isArray(changes)) { | ||
changes = Core$1.diff(changes, this._state); | ||
} | ||
for (j = 0, len = changes.length; j < len; j++) { | ||
change = changes[j]; | ||
this.replace.apply(this, change); | ||
} | ||
}); | ||
} | ||
@@ -974,4 +993,4 @@ if (arguments.length === 2) { | ||
this._disposables.push(selector.subscribe((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -985,7 +1004,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
})); | ||
@@ -996,4 +1011,4 @@ continue; | ||
selection.then((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -1007,7 +1022,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
}); | ||
@@ -1025,17 +1036,7 @@ continue; | ||
return selector.then((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
}); | ||
} | ||
return this._disposables.push(selector.subscribe((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
})); | ||
@@ -1259,54 +1260,66 @@ })(key, selector); | ||
set() { | ||
var changes, j, k, len, notify, path, property, ref, ref1, ref2, state, subKeys, subPaths, subs, value; | ||
var args, ref; | ||
if ((ref = Core$1.context) != null ? ref.pure : void 0) { | ||
return console.log('Cannot update in a Selector'); | ||
} | ||
if (arguments.length === 1) { | ||
ref1 = arguments[0]; | ||
for (property in ref1) { | ||
value = ref1[property]; | ||
this._setProperty(property, value); | ||
args = arguments; | ||
return Core$1.run(() => { | ||
var change, changes, j, k, l, len, len1, notify, path, property, ref1, ref2, ref3, state, subKeys, subPaths, subs, value; | ||
if (args.length === 1) { | ||
if (Array.isArray(args[0])) { | ||
ref1 = args[0]; | ||
for (j = 0, len = ref1.length; j < len; j++) { | ||
change = ref1[j]; | ||
this.set.apply(this, change); | ||
} | ||
} else { | ||
ref2 = args[0]; | ||
for (property in ref2) { | ||
value = ref2[property]; | ||
this._setProperty(property, value); | ||
} | ||
} | ||
return; | ||
} | ||
return; | ||
} | ||
changes = arguments[arguments.length - 1]; | ||
({state, subs, subPaths} = this._resolvePath(arguments, arguments.length - 1)); | ||
if (!state) { | ||
return; | ||
} | ||
notify = Array.isArray(state); | ||
for (property in changes) { | ||
value = changes[property]; | ||
notify = notify || !(indexOf.call(state, property) >= 0); | ||
if (value === void 0) { | ||
delete state[property]; | ||
} else { | ||
state[property] = value; | ||
changes = args[args.length - 1]; | ||
({state, subs, subPaths} = this._resolvePath(args, args.length - 1)); | ||
if (!state) { | ||
return; | ||
} | ||
if (subs) { | ||
this.trigger(subs != null ? (ref2 = subs[property]) != null ? ref2._subs : void 0 : void 0, value); | ||
notify = Array.isArray(state); | ||
for (property in changes) { | ||
value = changes[property]; | ||
notify = notify || !(indexOf.call(state, property) >= 0); | ||
if (value === void 0) { | ||
delete state[property]; | ||
} else { | ||
state[property] = value; | ||
} | ||
if (subs) { | ||
this.trigger(subs != null ? (ref3 = subs[property]) != null ? ref3._subs : void 0 : void 0, value); | ||
} | ||
} | ||
} | ||
if (notify) { | ||
this.trigger(subs != null ? subs._subs : void 0, state); | ||
} | ||
for (j = 0, len = subPaths.length; j < len; j++) { | ||
path = subPaths[j]; | ||
this.trigger(path.subs, path.state); | ||
} | ||
// prune subs | ||
if (value === void 0) { | ||
delete subs[property]; | ||
} else if (Array.isArray(value) && !value.length) { | ||
subKeys = ['_subs', 'clock', '_subPath']; | ||
for (k in subs[property]) { | ||
if (!(indexOf.call(subKeys, k) >= 0)) { | ||
delete subs[property][k]; | ||
if (notify) { | ||
this.trigger(subs != null ? subs._subs : void 0, state); | ||
} | ||
for (l = 0, len1 = subPaths.length; l < len1; l++) { | ||
path = subPaths[l]; | ||
this.trigger(path.subs, path.state); | ||
} | ||
// prune subs | ||
if (value === void 0) { | ||
delete subs[property]; | ||
} else if (Array.isArray(value) && !value.length) { | ||
subKeys = ['_subs', 'clock', '_subPath']; | ||
for (k in subs[property]) { | ||
if (!(indexOf.call(subKeys, k) >= 0)) { | ||
delete subs[property][k]; | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
replace() { | ||
var change, j, l, len, len1, notify, path, property, ref, ref1, state, subPaths, subs, value; | ||
var changes, j, len, notify, path, property, ref, state, subPaths, subs, value; | ||
if (arguments.length === 1) { | ||
@@ -1316,7 +1329,13 @@ if (!(arguments[0] instanceof Object)) { | ||
} | ||
ref = Core$1.diff(arguments[0], this._state); | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
change = ref[j]; | ||
this.replace(change); | ||
} | ||
changes = arguments[0]; | ||
Core$1.run(() => { | ||
var change, j, len; | ||
if (!Array.isArray(changes)) { | ||
changes = Core$1.diff(changes, this._state); | ||
} | ||
for (j = 0, len = changes.length; j < len; j++) { | ||
change = changes[j]; | ||
this.replace.apply(this, change); | ||
} | ||
}); | ||
return; | ||
@@ -1346,3 +1365,3 @@ } | ||
if (subs) { | ||
this.trigger((ref1 = subs[property]) != null ? ref1._subs : void 0, value); | ||
this.trigger((ref = subs[property]) != null ? ref._subs : void 0, value); | ||
} | ||
@@ -1352,4 +1371,4 @@ if (notify) { | ||
} | ||
for (l = 0, len1 = subPaths.length; l < len1; l++) { | ||
path = subPaths[l]; | ||
for (j = 0, len = subPaths.length; j < len; j++) { | ||
path = subPaths[j]; | ||
this.trigger(path.subs, path.state); | ||
@@ -1366,4 +1385,4 @@ } | ||
this._disposables.push(selector.subscribe((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -1377,7 +1396,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
})); | ||
@@ -1388,4 +1403,4 @@ continue; | ||
selection.then((value) => { | ||
var change, key, l, len1, ref, val; | ||
ref = [].concat(...((function() { | ||
var key, val; | ||
this.replace([].concat(...((function() { | ||
var ref, results; | ||
@@ -1399,7 +1414,3 @@ ref = value || {}; | ||
return results; | ||
}).call(this))); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
}).call(this)))); | ||
}); | ||
@@ -1417,17 +1428,7 @@ continue; | ||
return selector.then((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
}); | ||
} | ||
return this._disposables.push(selector.subscribe((value) => { | ||
var change, l, len1, ref; | ||
ref = Core$1.diff(value, this._state[key], [key]); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
change = ref[l]; | ||
this.replace(...change); | ||
} | ||
this.replace(Core$1.diff(value, this._state[key], [key])); | ||
})); | ||
@@ -1454,15 +1455,9 @@ })(key, selector); | ||
trigger(subs, value) { | ||
var sub; | ||
if (!(subs != null ? subs.size : void 0)) { | ||
return; | ||
} | ||
return Core$1.run(function() { | ||
var sub; | ||
for (sub of subs) { | ||
if (sub.handle != null) { | ||
Core$1.cancelTask(sub.handle, sub.defer); | ||
} | ||
sub.value = value; | ||
sub.handle = Core$1.queueTask(sub, sub.defer); | ||
} | ||
}); | ||
for (sub of subs) { | ||
Core$1.queueTask(sub, value); | ||
} | ||
} | ||
@@ -1469,0 +1464,0 @@ |
{ | ||
"name": "solid-js", | ||
"description": "A declarative JavaScript library for building user interfaces.", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Ryan Carniato", | ||
@@ -17,6 +17,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"babel-plugin-jsx-dom-expressions": "0.0.13" | ||
"babel-plugin-jsx-dom-expressions": "0.0.14" | ||
}, | ||
"devDependencies": { | ||
"coffeescript": "2.x", | ||
"coffeescript": "2.2.3", | ||
"rollup": "^0.58.1", | ||
@@ -23,0 +23,0 @@ "rollup-plugin-coffee2": "^0.1.15", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102801
2914
+ Addedbabel-plugin-jsx-dom-expressions@0.0.14(transitive)
- Removedbabel-plugin-jsx-dom-expressions@0.0.13(transitive)