microcosm
Advanced tools
Comparing version 3.0.0 to 3.1.0
# Changelog | ||
### 3.1.0 | ||
- `Microcosm::getInitialState()` now accepts an `options` | ||
argument. This argument is passed down from the constructor. | ||
### 3.0.0 | ||
@@ -4,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
module.exports=function(t){function r(e){if(n[e])return n[e].exports;var i=n[e]={exports:{},id:e,loaded:!1};return t[e].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}var n={};return r.m=t,r.c=n,r.p="",r(0)}([function(t,r,n){"use strict";r.__esModule=!0;var e=n(7);r.tag=e,r["default"]=n(2)},function(t){"use strict";function r(t,r){return t.reduce(function(t,n){return t[n]=r(n),t},{})}t.exports=r},function(t,r,n){"use strict";var e=function(t){return t&&t.__esModule?t["default"]:t},i=function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")},o=e(n(3)),s=e(n(4)),u=e(n(5)),a=e(n(8)),c=e(n(1)),f=e(n(6)),p=function(){function t(){i(this,t),f(this),this._state=this.getInitialState(),this._stores=[]}return t.prototype.getInitialState=function(){return{}},t.prototype.shouldUpdate=function(t,r){return a(t,r)===!1},t.prototype.has=function(t){return this._stores.some(function(r){return""+t==""+r})},t.prototype.get=function(t){return this._state[t]},t.prototype.swap=function(t){this.reset(u(this._state,t))},t.prototype.reset=function(t){this.shouldUpdate(this._state,t)&&(this._state=t,this.pump())},t.prototype.prepare=function(t){for(var r,n=arguments.length,e=Array(n>1?n-1:0),i=1;n>i;i++)e[i-1]=arguments[i];return(r=this.send).bind.apply(r,[this,t].concat(e))},t.prototype.send=function(t){for(var r=this,n=arguments.length,e=Array(n>1?n-1:0),i=1;n>i;i++)e[i-1]=arguments[i];var o=t.apply(this,e);return o instanceof Promise?o.then(function(n){return r.dispatch(t,n)}):this.dispatch(t,o)},t.prototype.dispatch=function(t,r){var n=this,e=this._stores.filter(function(r){return t in r}),i=c(e,function(e){return e[t](n.get(e),r)});return this.swap(i),r},t.prototype.addStore=function(t){var r=u(o,t);s(!this.has(r),'Tried to add "'+t+'" but it is not unique'),this._stores.push(r),this.swap(function(){var t={};return t[r]=r.getInitialState(),t}())},t.prototype.serialize=function(){var t=this;return c(this._stores,function(r){return r.serialize(t.get(r))})},t.prototype.deserialize=function(){var t=void 0===arguments[0]?{}:arguments[0];return c(this._stores,function(r){return r.deserialize(t[r])})},t.prototype.seed=function(t){this.reset(this.deserialize(t))},t.prototype.toJSON=function(){return this.serialize()},t}();t.exports=p},function(t){"use strict";t.exports={getInitialState:function(){return void 0},serialize:function(t){return t},deserialize:function(){var t=void 0===arguments[0]?this.getInitialState():arguments[0];return t},toString:function(){throw new Error("Stores must implement a toString() method")}}},function(t){"use strict";function r(t,r){if(!t){var n=new Error(r);throw n.framesToPop=1,n}}t.exports=r},function(t){"use strict";function r(t,r){return n({},t,r)}var n=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t};t.exports=r},function(t){"use strict";function r(){var t=void 0===arguments[0]?{}:arguments[0],r=[];return t.ignore=function(t){r=r.filter(function(r){return r!==t})},t.listen=function(t){r.push(t)},t.pump=function(){for(var t=0;t<r.length;t++)r[t].call(this)},t}t.exports=r},function(t,r,n){"use strict";function e(t){return"function"==typeof t}function i(t,r){var n=t.bind(null),e="_"+r+"_"+u++;return n.toString=function(){return e},n}var o=function(t){return t&&t.__esModule?t["default"]:t},s=o(n(1)),u=0;t.exports=function(t){return s(Object.keys(t),function(r){var n=t[r];return e(n)?i(n,r):n})}},function(t,r,n){/*! | ||
module.exports=function(t){function r(e){if(n[e])return n[e].exports;var i=n[e]={exports:{},id:e,loaded:!1};return t[e].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}var n={};return r.m=t,r.c=n,r.p="",r(0)}([function(t,r,n){"use strict";r.__esModule=!0;var e=n(7);r.tag=e,r["default"]=n(2)},function(t){"use strict";function r(t,r){return t.reduce(function(t,n){return t[n]=r(n),t},{})}t.exports=r},function(t,r,n){"use strict";var e=function(t){return t&&t.__esModule?t["default"]:t},i=function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")},o=e(n(3)),s=e(n(4)),u=e(n(5)),a=e(n(8)),c=e(n(1)),f=e(n(6)),p=function(){function t(r){i(this,t),f(this),this._state=this.getInitialState(r),this._stores=[]}return t.prototype.getInitialState=function(){return{}},t.prototype.shouldUpdate=function(t,r){return a(t,r)===!1},t.prototype.has=function(t){return this._stores.some(function(r){return""+t==""+r})},t.prototype.get=function(t){return this._state[t]},t.prototype.swap=function(t){this.reset(u(this._state,t))},t.prototype.reset=function(t){this.shouldUpdate(this._state,t)&&(this._state=t,this.pump())},t.prototype.prepare=function(t){for(var r,n=arguments.length,e=Array(n>1?n-1:0),i=1;n>i;i++)e[i-1]=arguments[i];return(r=this.send).bind.apply(r,[this,t].concat(e))},t.prototype.send=function(t){for(var r=this,n=arguments.length,e=Array(n>1?n-1:0),i=1;n>i;i++)e[i-1]=arguments[i];var o=t.apply(this,e);return o instanceof Promise?o.then(function(n){return r.dispatch(t,n)}):this.dispatch(t,o)},t.prototype.dispatch=function(t,r){var n=this,e=this._stores.filter(function(r){return t in r}),i=c(e,function(e){return e[t](n.get(e),r)});return this.swap(i),r},t.prototype.addStore=function(t){var r=u(o,t);s(!this.has(r),'Tried to add "'+t+'" but it is not unique'),this._stores.push(r),this.swap(function(){var t={};return t[r]=r.getInitialState(),t}())},t.prototype.serialize=function(){var t=this;return c(this._stores,function(r){return r.serialize(t.get(r))})},t.prototype.deserialize=function(){var t=void 0===arguments[0]?{}:arguments[0];return c(this._stores,function(r){return r.deserialize(t[r])})},t.prototype.seed=function(t){this.reset(this.deserialize(t))},t.prototype.toJSON=function(){return this.serialize()},t}();t.exports=p},function(t){"use strict";t.exports={getInitialState:function(){return void 0},serialize:function(t){return t},deserialize:function(){var t=void 0===arguments[0]?this.getInitialState():arguments[0];return t},toString:function(){throw new Error("Stores must implement a toString() method")}}},function(t){"use strict";function r(t,r){if(!t){var n=new Error(r);throw n.framesToPop=1,n}}t.exports=r},function(t){"use strict";function r(t,r){return n({},t,r)}var n=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t};t.exports=r},function(t){"use strict";function r(){var t=void 0===arguments[0]?{}:arguments[0],r=[];return t.ignore=function(t){r=r.filter(function(r){return r!==t})},t.listen=function(t){r.push(t)},t.pump=function(){for(var t=0;t<r.length;t++)r[t].call(this)},t}t.exports=r},function(t,r,n){"use strict";function e(t){return"function"==typeof t}function i(t,r){var n=t.bind(null),e="_"+r+"_"+u++;return n.toString=function(){return e},n}var o=function(t){return t&&t.__esModule?t["default"]:t},s=o(n(1)),u=0;t.exports=function(t){return s(Object.keys(t),function(r){var n=t[r];return e(n)?i(n,r):n})}},function(t,r,n){/*! | ||
* is-equal-shallow <https://github.com/jonschlinkert/is-equal-shallow> | ||
@@ -3,0 +3,0 @@ * |
{ | ||
"name": "microcosm", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "A functional flux architecture", | ||
@@ -5,0 +5,0 @@ "main": "dist/Microcosm.js", |
@@ -23,5 +23,4 @@ [![NPM](https://nodei.co/npm/microcosm.png?compact=true)](https://npmjs.org/package/microcosm) | ||
Microcosm is an experimental Flux inspired by | ||
[Flummox](https://github.com/acdlite/flummox) and many ideas within | ||
[Elm](http://elm-lang.org). It is an | ||
Microcosm is an experimental Flux inspired by [Om](https://github.com/omcljs/om), | ||
[Flummox](https://github.com/acdlite/flummox) and [Elm](http://elm-lang.org). It is an | ||
[isomorphic](http://artsy.github.io/blog/2013/11/30/rendering-on-the-server-and-client-in-node-dot-js/) | ||
@@ -28,0 +27,0 @@ [Flux](http://facebook.github.io/flux). |
@@ -16,6 +16,6 @@ /** | ||
constructor() { | ||
constructor(options) { | ||
pulse(this) | ||
this._state = this.getInitialState() | ||
this._state = this.getInitialState(options) | ||
this._stores = [] | ||
@@ -22,0 +22,0 @@ } |
Sorry, the diff of this file is not supported yet
142023
300