@erickmerchant/framework
Advanced tools
Comparing version 9.1.0 to 9.2.0
@@ -8,2 +8,3 @@ "use strict"; | ||
diff = _ref.diff, | ||
options = _ref.options, | ||
raf = _ref.raf; | ||
@@ -13,3 +14,12 @@ | ||
var state = store(); | ||
options = options != null ? Object.assign({}, options, { dispatch: dispatch, next: next }) : { dispatch: dispatch, next: next }; | ||
var stores = store; | ||
if (!Array.isArray(store)) { | ||
stores = [store]; | ||
} | ||
var state = stores.reduce(function (state, store) { | ||
return store(state); | ||
}); | ||
var rafCalled = false; | ||
@@ -22,4 +32,8 @@ | ||
function dispatch() { | ||
state = store.apply(undefined, [state].concat(Array.prototype.slice.call(arguments))); | ||
var _arguments = arguments; | ||
state = stores.reduce(function (state, store) { | ||
return store.apply(undefined, [state].concat(Array.prototype.slice.call(_arguments))); | ||
}, state); | ||
if (!rafCalled) { | ||
@@ -35,3 +49,3 @@ rafCalled = true; | ||
var element = component({ state: state, dispatch: dispatch, next: next }); | ||
var element = component(Object.assign({ state: state }, options)); | ||
@@ -38,0 +52,0 @@ if (element != null) { |
15
main.js
@@ -1,5 +0,12 @@ | ||
module.exports = function ({target, store, component, diff, raf}) { | ||
module.exports = function ({target, store, component, diff, options, raf}) { | ||
raf = raf != null ? raf : window.requestAnimationFrame | ||
let state = store() | ||
options = options != null ? Object.assign({}, options, {dispatch, next}) : {dispatch, next} | ||
let stores = store | ||
if (!Array.isArray(store)) { | ||
stores = [store] | ||
} | ||
let state = stores.reduce((state, store) => store(state)) | ||
let rafCalled = false | ||
@@ -12,3 +19,3 @@ | ||
function dispatch () { | ||
state = store(state, ...arguments) | ||
state = stores.reduce((state, store) => store(state, ...arguments), state) | ||
@@ -25,3 +32,3 @@ if (!rafCalled) { | ||
const element = component({state, dispatch, next}) | ||
const element = component(Object.assign({state}, options)) | ||
@@ -28,0 +35,0 @@ if (element != null) { |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "9.1.0", | ||
"version": "9.2.0", | ||
"description": "A simple data down, actions up framework.", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -126,8 +126,12 @@ # @erickmerchant/framework | ||
- [@erickmerchant/state-container](https://github.com/erickmerchant/state-container) | ||
- [@erickmerchant/combine-stores](https://github.com/erickmerchant/combine-stores) | ||
A state container to use as a store | ||
A module to create a store from other stores where each is responsible for one property in the state. | ||
- [@erickmerchant/router](https://github.com/erickmerchant/router) | ||
A module to do routing inside your components. | ||
- [A TodoMVC example](http://todo.erickmerchant.com) | ||
The source code can be found [here](https://github.com/erickmerchant/framework-todo) |
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
8712
139
137