Comparing version 0.9.3 to 0.9.4
@@ -56,3 +56,3 @@ "use strict"; | ||
this.listeners = {}; | ||
this.listenersByProps = {}; | ||
this.listenersByProp = {}; | ||
this.state = state; | ||
@@ -115,4 +115,4 @@ | ||
key: "getSync", | ||
value: function getSync(props) { | ||
return _camelDotPropImmutable2.default.get(this.state, props); | ||
value: function getSync(prop) { | ||
return _camelDotPropImmutable2.default.get(this.state, prop); | ||
} | ||
@@ -207,7 +207,7 @@ }, { | ||
}, { | ||
key: "addListenerByProps", | ||
value: function addListenerByProps(props, listener) { | ||
this.listenersByProps[props] = this.listenersByProps[props] || []; | ||
key: "addListenerByProp", | ||
value: function addListenerByProp(prop, listener) { | ||
this.listenersByProp[prop] = this.listenersByProp[prop] || []; | ||
this.listenersByProps[props] = this.listenersByProps[props].concat([listener]); | ||
this.listenersByProp[prop] = this.listenersByProp[prop].concat([listener]); | ||
} | ||
@@ -414,7 +414,7 @@ }, { | ||
key: "on", | ||
value: function on(props, fn) { | ||
value: function on(prop, fn) { | ||
var listener = function listener(options) { | ||
var detectChange = options.detectChange; | ||
if (detectChange(props)) { | ||
if (detectChange(prop)) { | ||
fn(options); | ||
@@ -424,3 +424,3 @@ } | ||
this.addListenerByProps(props, listener); | ||
this.addListenerByProps(prop, listener); | ||
this.subscribe(listener); | ||
@@ -432,6 +432,6 @@ | ||
key: "off", | ||
value: function off(props) { | ||
var listeners = this.listenersByProps[props]; | ||
value: function off(prop) { | ||
var listeners = this.listenersByProp[prop]; | ||
this.listenersByProps[props] = []; | ||
this.listenersByProp[prop] = []; | ||
@@ -467,3 +467,3 @@ var _iteratorNormalCompletion4 = true; | ||
key: "once", | ||
value: function once(props, fn) { | ||
value: function once(prop, fn) { | ||
var ran = false; | ||
@@ -479,3 +479,3 @@ | ||
if (detectChange(props)) { | ||
if (detectChange(prop)) { | ||
ran = true; | ||
@@ -486,3 +486,3 @@ fn(options); | ||
this.addListenerByProps(props, listener); | ||
this.addListenerByProps(prop, listener); | ||
this.subscribe(listener); | ||
@@ -492,2 +492,19 @@ | ||
} | ||
}, { | ||
key: "oncePresent", | ||
value: function oncePresent(prop, fn) { | ||
var value = this.getSync(prop); | ||
if (value) { | ||
fn({ | ||
prop: prop, | ||
props: (0, _string.propSplit)(prop), | ||
state: this.state, | ||
store: this, | ||
value: value | ||
}); | ||
} else { | ||
this.once(prop, fn); | ||
} | ||
} | ||
}]); | ||
@@ -494,0 +511,0 @@ return DotStore; |
{ | ||
"name": "dot-store", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Like Redux, but easy", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
28306
445