Comparing version 0.0.2 to 0.0.3
@@ -95,2 +95,6 @@ (function (global, factory) { | ||
} ); | ||
store.subscribeViewUpdate( function () { | ||
devtools.emit( 'reo:view-updated' ); | ||
} ); | ||
}; }; | ||
@@ -113,2 +117,3 @@ | ||
_subscribers: [], | ||
_viewUpdateSubscribers: [], | ||
_queue: [], | ||
@@ -225,2 +230,3 @@ _updateTid: null, | ||
this._host.$update(); | ||
this._viewUpdateSubscribers.forEach( function (fn) { return fn(); } ); | ||
}; | ||
@@ -237,2 +243,9 @@ Store.prototype.host = function host ( target ) { | ||
}; | ||
Store.prototype.subscribeViewUpdate = function subscribeViewUpdate ( fn ) { | ||
if ( typeof fn !== 'function' ) { | ||
return; | ||
} | ||
this._viewUpdateSubscribers.push( fn ); | ||
}; | ||
Store.prototype.registerModule = function registerModule ( name, module ) { | ||
@@ -243,3 +256,3 @@ if ( name === void 0 ) { name = ''; } | ||
if ( !name ) { | ||
return console.error( 'Please provide name when register module' ); | ||
return console.error( 'Please provide a name when register module' ); | ||
} | ||
@@ -246,0 +259,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.AMO=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=t(function(t,o){!function(e,n){"object"==typeof o&&"undefined"!=typeof t?t.exports=n():"function"==typeof define&&define.amd?define(n):e.regux=n()}(e,function(){function t(t,e){var o={};return Object.keys(t).forEach(function(n){o[e+"/"+n]=t[n]}),o}function e(t){return"undefined"!=typeof t.type}function o(t){return t&&t instanceof s}var n=function(){function t(t){return function(e){return t.call(e,e.data)}}function e(t){return function(e,o){return t.call(e,o,e.data),o}}return function(o){if(o){var n,r,i,s={};for(var u in o)n=o[u],i=typeof n,"expression"!==n.type?"string"!==i&&(r=s[u]={type:"expression"},"function"===i?r.get=t(n):(n.get&&(r.get=t(n.get)),n.set&&(r.set=e(n.set)))):s[u]=n;return s}}}(),r=function(t,e){Object.assign(t.computed||{},n(e))},i=function(){return function(t){var e=window.__REO_DEVTOOLS_HOOK__;e&&(t._devtools=e,e.emit("reo:init",t),e.on("reo:travel-to-state",function(e){t.replaceState(e)}),t.subscribe(function(t,o){e.emit("reo:reducer",t,o)}))}},s=function(t){var e=this;void 0===t&&(t={});var o=t.modules;void 0===o&&(o={});var n=t.actions;void 0===n&&(n={});var r=t.plugins;void 0===r&&(r=[]),Object.assign(this,{_state:{},_reducers:{},_modules:o,_getters:{},_actions:n,_plugins:r,_subscribers:[],_queue:[],_updateTid:null}),Object.keys(o).forEach(function(t){return e.registerModule(t,o[t])}),i()(this),r.forEach(function(t){return e.use(t)})};s.prototype.use=function(t){t(this)},s.prototype.replaceState=function(t){this._state=t,this.updateView()},s.prototype.getState=function(){return this._state},s.prototype.getGetters=function(){return this._getters},s.prototype.nextTick=function(){for(var t=arguments,e=[],o=arguments.length;o--;)e[o]=t[o];return this.queue.apply(this,e)},s.prototype.queue=function(t){this._queue.push(t)},s.prototype.dequeue=function(){var t=this._queue;t.forEach(function(t){"function"==typeof t&&t()}),this._queue.length=0},s.prototype.dispatch=function(t,o){var n;if("string"==typeof t)n={type:t,payload:o};else{if(!e(t))return console.error("invalid dispatch params",arguments);n=t}var r=this._actions[n.type];return"function"!=typeof r?console.error("action",n.type,"not found"):r({state:this.getState(),commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),nextTick:this.nextTick.bind(this)},n.payload)},s.prototype.commit=function(t,o){var n,r=this;if("string"==typeof t)n={type:t,payload:o};else{if(!e(t))return console.error("invalid commit params",arguments);n=t}var i=this._reducers[n.type];if("function"==typeof i){var s=this.getState(),u="undefined"==typeof i.key?s:s[i.key];i(u,n.payload),this._applySubscribers(n,s),this._updateTid&&clearTimeout(this._updateTid),this._updateTid=setTimeout(function(){r.updateView(),r.dequeue()},0)}else console.error("reducer",n.type,"not found")},s.prototype.updateView=function(){this._host.$update()},s.prototype.host=function(t){this._host=t},s.prototype.subscribe=function(t){"function"==typeof t&&this._subscribers.push(t)},s.prototype.registerModule=function(e,o){if(void 0===e&&(e=""),void 0===o&&(o={}),!e)return console.error("Please provide name when register module");this._state[e]=o.state||{};var n=o.reducers||{};for(var r in n)n[r].key=e;n=t(n,e),Object.assign(this._reducers,n)},s.prototype.registerActions=function(t){void 0===t&&(t={}),Object.assign(this._actions,t)},s.prototype.registerGetters=function(t){void 0===t&&(t={}),Object.assign(this._getters,t)},s.prototype._applySubscribers=function(t,e){for(var o=this._subscribers,n=0,r=o.length;n<r;n++){var i=o[n];i(t,e)}};var u=function(t){var e;t.implement({events:{$config:function(){if(o(this.store)&&(e?(console.groupCollapsed("store already exists"),console.log("old store:",e),console.log("new store:",this.store),console.groupEnd("store already exists"),console.warn("old store will be used")):(e=this.store,e.host(this),delete this.store)),!e)return console.error("store not found");this.$store=e,this.commit=e.commit.bind(e),this.dispatch=e.dispatch.bind(e),this.nextTick=e.nextTick.bind(e);var t=e.getGetters(),n=this,i=n.getters;void 0===i&&(i={}),Object.keys(i).forEach(function(o){var n=i[o];"string"==typeof n&&(n=t[n]),"function"==typeof n&&(i[o]=function(){return n(e.getState())})}),r(this,i)}}})};return u.Store=s,u})}),n=t(function(t,o){!function(e,n){"object"==typeof o&&"undefined"!=typeof t?t.exports=n():"function"==typeof define&&define.amd?define(n):e.logger=n()}(e,function(){function t(t){void 0===t&&(t={});var e=t.collapsed;void 0===e&&(e=!0);var n=t.transformer;void 0===n&&(n=function(t){return t});var r=t.mutationTransformer;return void 0===r&&(r=function(t){return t}),function(t){var i=JSON.parse(JSON.stringify(t.getState()));t.subscribe(function(t,s){var u=JSON.parse(JSON.stringify(s)),c=new Date,f=" @ "+o(c.getHours(),2)+":"+o(c.getMinutes(),2)+":"+o(c.getSeconds(),2)+"."+o(c.getMilliseconds(),3),a="commit "+t.type+f;e?console.groupCollapsed(a):console.group(a),console.log("%c prev state","color: #9E9E9E; font-weight: bold",n(i)),console.log("%c commit","color: #03A9F4; font-weight: bold",r(t)),console.log("%c next state","color: #4CAF50; font-weight: bold",n(u)),console.groupEnd(a),i=u})}}function e(t,e){return new Array(e+1).join(t)}function o(t,o){return e("0",o-t.toString().length)+t}return t})}),r=function(){var t=new o.Store;t.use(n()),this._store=t};r.prototype.getStore=function(){return this._store},r.prototype.use=function(t){t.use(o)},r.prototype.model=function(t){void 0===t&&(t={});var e=t.name;if(!e)return console.error("Please provide name for model",t);var o=this.getStore();o.registerModule(e,t)},r.prototype.getters=function t(t){var e=this.getStore();e.registerGetters(t)},r.prototype.actions=function t(t){void 0===t&&(t={});var e=this.getStore();e.registerActions(t)},r.prototype.start=function(t,e){return new t({store:this.getStore()}).$inject(document.querySelector(e))};var i=function(){return new r};return i}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.AMO=e()}(this,function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=t(function(t,o){!function(e,n){"object"==typeof o&&"undefined"!=typeof t?t.exports=n():"function"==typeof define&&define.amd?define(n):e.regux=n()}(e,function(){function t(t,e){var o={};return Object.keys(t).forEach(function(n){o[e+"/"+n]=t[n]}),o}function e(t){return"undefined"!=typeof t.type}function o(t){return t&&t instanceof s}var n=function(){function t(t){return function(e){return t.call(e,e.data)}}function e(t){return function(e,o){return t.call(e,o,e.data),o}}return function(o){if(o){var n,r,i,s={};for(var u in o)n=o[u],i=typeof n,"expression"!==n.type?"string"!==i&&(r=s[u]={type:"expression"},"function"===i?r.get=t(n):(n.get&&(r.get=t(n.get)),n.set&&(r.set=e(n.set)))):s[u]=n;return s}}}(),r=function(t,e){Object.assign(t.computed||{},n(e))},i=function(){return function(t){var e=window.__REO_DEVTOOLS_HOOK__;e&&(t._devtools=e,e.emit("reo:init",t),e.on("reo:travel-to-state",function(e){t.replaceState(e)}),t.subscribe(function(t,o){e.emit("reo:reducer",t,o)}),t.subscribeViewUpdate(function(){e.emit("reo:view-updated")}))}},s=function(t){var e=this;void 0===t&&(t={});var o=t.modules;void 0===o&&(o={});var n=t.actions;void 0===n&&(n={});var r=t.plugins;void 0===r&&(r=[]),Object.assign(this,{_state:{},_reducers:{},_modules:o,_getters:{},_actions:n,_plugins:r,_subscribers:[],_viewUpdateSubscribers:[],_queue:[],_updateTid:null}),Object.keys(o).forEach(function(t){return e.registerModule(t,o[t])}),i()(this),r.forEach(function(t){return e.use(t)})};s.prototype.use=function(t){t(this)},s.prototype.replaceState=function(t){this._state=t,this.updateView()},s.prototype.getState=function(){return this._state},s.prototype.getGetters=function(){return this._getters},s.prototype.nextTick=function(){for(var t=arguments,e=[],o=arguments.length;o--;)e[o]=t[o];return this.queue.apply(this,e)},s.prototype.queue=function(t){this._queue.push(t)},s.prototype.dequeue=function(){var t=this._queue;t.forEach(function(t){"function"==typeof t&&t()}),this._queue.length=0},s.prototype.dispatch=function(t,o){var n;if("string"==typeof t)n={type:t,payload:o};else{if(!e(t))return console.error("invalid dispatch params",arguments);n=t}var r=this._actions[n.type];return"function"!=typeof r?console.error("action",n.type,"not found"):r({state:this.getState(),commit:this.commit.bind(this),dispatch:this.dispatch.bind(this),nextTick:this.nextTick.bind(this)},n.payload)},s.prototype.commit=function(t,o){var n,r=this;if("string"==typeof t)n={type:t,payload:o};else{if(!e(t))return console.error("invalid commit params",arguments);n=t}var i=this._reducers[n.type];if("function"==typeof i){var s=this.getState(),u="undefined"==typeof i.key?s:s[i.key];i(u,n.payload),this._applySubscribers(n,s),this._updateTid&&clearTimeout(this._updateTid),this._updateTid=setTimeout(function(){r.updateView(),r.dequeue()},0)}else console.error("reducer",n.type,"not found")},s.prototype.updateView=function(){this._host.$update(),this._viewUpdateSubscribers.forEach(function(t){return t()})},s.prototype.host=function(t){this._host=t},s.prototype.subscribe=function(t){"function"==typeof t&&this._subscribers.push(t)},s.prototype.subscribeViewUpdate=function(t){"function"==typeof t&&this._viewUpdateSubscribers.push(t)},s.prototype.registerModule=function(e,o){if(void 0===e&&(e=""),void 0===o&&(o={}),!e)return console.error("Please provide a name when register module");this._state[e]=o.state||{};var n=o.reducers||{};for(var r in n)n[r].key=e;n=t(n,e),Object.assign(this._reducers,n)},s.prototype.registerActions=function(t){void 0===t&&(t={}),Object.assign(this._actions,t)},s.prototype.registerGetters=function(t){void 0===t&&(t={}),Object.assign(this._getters,t)},s.prototype._applySubscribers=function(t,e){for(var o=this._subscribers,n=0,r=o.length;n<r;n++){var i=o[n];i(t,e)}};var u=function(t){var e;t.implement({events:{$config:function(){if(o(this.store)&&(e?(console.groupCollapsed("store already exists"),console.log("old store:",e),console.log("new store:",this.store),console.groupEnd("store already exists"),console.warn("old store will be used")):(e=this.store,e.host(this),delete this.store)),!e)return console.error("store not found");this.$store=e,this.commit=e.commit.bind(e),this.dispatch=e.dispatch.bind(e),this.nextTick=e.nextTick.bind(e);var t=e.getGetters(),n=this,i=n.getters;void 0===i&&(i={}),Object.keys(i).forEach(function(o){var n=i[o];"string"==typeof n&&(n=t[n]),"function"==typeof n&&(i[o]=function(){return n(e.getState())})}),r(this,i)}}})};return u.Store=s,u})}),n=t(function(t,o){!function(e,n){"object"==typeof o&&"undefined"!=typeof t?t.exports=n():"function"==typeof define&&define.amd?define(n):e.logger=n()}(e,function(){function t(t){void 0===t&&(t={});var e=t.collapsed;void 0===e&&(e=!0);var n=t.transformer;void 0===n&&(n=function(t){return t});var r=t.mutationTransformer;return void 0===r&&(r=function(t){return t}),function(t){var i=JSON.parse(JSON.stringify(t.getState()));t.subscribe(function(t,s){var u=JSON.parse(JSON.stringify(s)),c=new Date,f=" @ "+o(c.getHours(),2)+":"+o(c.getMinutes(),2)+":"+o(c.getSeconds(),2)+"."+o(c.getMilliseconds(),3),a="commit "+t.type+f;e?console.groupCollapsed(a):console.group(a),console.log("%c prev state","color: #9E9E9E; font-weight: bold",n(i)),console.log("%c commit","color: #03A9F4; font-weight: bold",r(t)),console.log("%c next state","color: #4CAF50; font-weight: bold",n(u)),console.groupEnd(a),i=u})}}function e(t,e){return new Array(e+1).join(t)}function o(t,o){return e("0",o-t.toString().length)+t}return t})}),r=function(){var t=new o.Store;t.use(n()),this._store=t};r.prototype.getStore=function(){return this._store},r.prototype.use=function(t){t.use(o)},r.prototype.model=function(t){void 0===t&&(t={});var e=t.name;if(!e)return console.error("Please provide name for model",t);var o=this.getStore();o.registerModule(e,t)},r.prototype.getters=function t(t){var e=this.getStore();e.registerGetters(t)},r.prototype.actions=function t(t){void 0===t&&(t={});var e=this.getStore();e.registerActions(t)},r.prototype.start=function(t,e){return new t({store:this.getStore()}).$inject(document.querySelector(e))};var i=function(){return new r};return i}); | ||
//# sourceMappingURL=amo.min.js.map |
{ | ||
"name": "amo", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "dist/amo.js", | ||
@@ -18,4 +18,4 @@ "scripts": { | ||
"onchange": "^3.2.0", | ||
"regux": "0.0.2" | ||
"regux": "0.0.3" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
225763
5321
0