Comparing version 1.0.0 to 1.1.0
@@ -104,2 +104,3 @@ "use strict"; | ||
this.state = result; | ||
this.ctx.slots._fireOnSet(this); | ||
return this; | ||
@@ -106,0 +107,0 @@ } |
@@ -44,2 +44,4 @@ "use strict"; | ||
this.onPromiseErrorListeners = []; | ||
this.onSetListeners = []; | ||
this.onCommitListeners = []; | ||
} | ||
@@ -89,2 +91,3 @@ | ||
}); | ||
this._fireOnCommit(ctx); | ||
d("LISTENERS DONE", (0, _utils.insp)(ctx.state)); | ||
@@ -171,2 +174,26 @@ return ctx; | ||
}, { | ||
key: "onSet", | ||
value: function onSet(fn) { | ||
this.onSetListeners.push(fn); | ||
} | ||
}, { | ||
key: "_fireOnSet", | ||
value: function _fireOnSet(branch) { | ||
this.onSetListeners.forEach(function (fn) { | ||
return fn(branch); | ||
}); | ||
} | ||
}, { | ||
key: "onCommit", | ||
value: function onCommit(fn) { | ||
this.onCommitListeners.push(fn); | ||
} | ||
}, { | ||
key: "_fireOnCommit", | ||
value: function _fireOnCommit(context) { | ||
this.onCommitListeners.forEach(function (fn) { | ||
return fn(context); | ||
}); | ||
} | ||
}, { | ||
key: "onPromisesAreMade", | ||
@@ -173,0 +200,0 @@ value: function onPromisesAreMade(fn) { |
{ | ||
"name": "slt", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Take care of your state", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -62,2 +62,3 @@ import { fromJS, is, Map, List} from "immutable"; | ||
this.state = result; | ||
this.ctx.slots._fireOnSet(this); | ||
return this; | ||
@@ -64,0 +65,0 @@ } |
@@ -21,2 +21,4 @@ import { fromJS, is, Map, List} from "immutable"; | ||
this.onPromiseErrorListeners = []; | ||
this.onSetListeners = []; | ||
this.onCommitListeners = []; | ||
} | ||
@@ -52,2 +54,3 @@ | ||
this.onChangeListeners.forEach(f => f(this.state.toJS())); | ||
this._fireOnCommit(ctx); | ||
d("LISTENERS DONE", insp(ctx.state)); | ||
@@ -122,2 +125,18 @@ return ctx; | ||
onSet(fn) { | ||
this.onSetListeners.push(fn); | ||
} | ||
_fireOnSet(branch) { | ||
this.onSetListeners.forEach(fn => fn(branch)); | ||
} | ||
onCommit(fn) { | ||
this.onCommitListeners.push(fn); | ||
} | ||
_fireOnCommit(context) { | ||
this.onCommitListeners.forEach(fn => fn(context)); | ||
} | ||
onPromisesAreMade(fn) { | ||
@@ -124,0 +143,0 @@ this.onPromisesAreMadeListeners.push(fn); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
93978
1230