zerofux
Version:
Use a unidirectional dataflow with Custom Events.
3 lines (2 loc) • 677 B
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.zerofux={})}(this,function(e){var t=function(e){this.dispatcher=e||document.querySelector("body")};t.prototype.dispatch=function(e){this.dispatcher.dispatchEvent(new CustomEvent(e.type,{detail:e,bubbles:!0,compose:!0}))},t.prototype.setReducers=function(e,t,o){var n=this;e.forEach(function(e){if(!t[e])throw new Error('Please add a reducer for the "'+e+'" action.');n.dispatcher.addEventListener(e,function(n){var r=n.detail;o.state=t[e](o.state,r)})})};var o=new t;e.ZeroFux=t,e.zeroFux=o});
//# sourceMappingURL=zerofux.umd.js.map