Comparing version 0.4.2 to 0.4.3
@@ -18,6 +18,7 @@ /** | ||
* @param {array} stores List of stores to listen for changes | ||
* @param {object} storeGetters Map of storeName => stateGetterMethod used to retrieve state from the store | ||
* @param {function} getStateFromStores function that receives all stores and should return | ||
* the full state object. Receives `stores` hash and component `props` as arguments | ||
* @returns {React.Component} | ||
*/ | ||
module.exports = function connectToStores(Component, stores, storeGetters) { | ||
module.exports = function connectToStores(Component, stores, getStateFromStores) { | ||
var componentName = Component.displayName || Component.name; | ||
@@ -43,5 +44,14 @@ var StoreConnector = React.createClass({ | ||
getStateFromStores: function () { | ||
if ('function' === typeof getStateFromStores) { | ||
var storeInstances = {}; | ||
stores.forEach(function (store) { | ||
var storeName = store.name || store.storeName || store; | ||
storeInstances[storeName] = this.context.getStore(store); | ||
}, this); | ||
return getStateFromStores(storeInstances, this.props); | ||
} | ||
var state = {}; | ||
Object.keys(storeGetters).forEach(function (storeName) { | ||
var stateGetter = storeGetters[storeName]; | ||
//@TODO deprecate? | ||
Object.keys(getStateFromStores).forEach(function (storeName) { | ||
var stateGetter = getStateFromStores[storeName]; | ||
var store = this.context.getStore(storeName); | ||
@@ -48,0 +58,0 @@ objectAssign(state, stateGetter(store, this.props)); |
# Change Log | ||
## 0.4.3 | ||
### Features | ||
* [#117] Add option to pass function to connectToStores which receives access to all stores | ||
### Bug Fixes | ||
* [#120] Fixed component action handler errors being swallowed - @cesarandreu | ||
## 0.4.2 | ||
### Bug Fixes | ||
* [#115] Moved factory warning to context.createElement since it's only relevant when using this method | ||
## 0.4.1 | ||
@@ -4,0 +20,0 @@ |
@@ -207,5 +207,10 @@ /** | ||
executeAction: function componentExecuteAction(action, payload) { | ||
self.executeAction(action, payload).catch(function actionHandlerWrapper(err) { | ||
var noop = function () {}; | ||
self.executeAction(self._app._componentActionHandler, { err: err }, noop); | ||
self.executeAction(action, payload) | ||
.catch(function actionHandlerWrapper(err) { | ||
return self.executeAction(self._app._componentActionHandler, { err: err }); | ||
}) | ||
.catch(function unhandledError(err) { | ||
setImmediate(function () { | ||
throw err; | ||
}); | ||
}); | ||
@@ -212,0 +217,0 @@ } |
{ | ||
"name": "fluxible", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "A pluggable container for isomorphic flux applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Fluxible | ||
[![npm version](https://img.shields.io/npm/v/fluxible.svg?style=flat-square)](https://www.npmjs.com/package/fluxible) | ||
[![Build Status](https://img.shields.io/travis/yahoo/fluxible.svg?style=flat-square)](https://travis-ci.org/yahoo/fluxible) | ||
[![Coverage Status](https://img.shields.io/coveralls/yahoo/fluxible.svg?style=flat-square)](https://coveralls.io/r/yahoo/fluxible?branch=master) | ||
[![Dependency Status](https://img.shields.io/david/yahoo/fluxible.svg?style=flat-square)](https://david-dm.org/yahoo/fluxible) | ||
[![devDependency Status](https://img.shields.io/david/dev/yahoo/fluxible.svg?style=flat-square)](https://david-dm.org/yahoo/fluxible#info=devDependencies) | ||
[![NPM version](https://badge.fury.io/js/fluxible.svg)](http://badge.fury.io/js/fluxible) | ||
[![Build Status](https://img.shields.io/travis/yahoo/fluxible.svg)](https://travis-ci.org/yahoo/fluxible) | ||
[![Coverage Status](https://img.shields.io/coveralls/yahoo/fluxible.svg)](https://coveralls.io/r/yahoo/fluxible?branch=master) | ||
[![Dependency Status](https://img.shields.io/david/yahoo/fluxible.svg)](https://david-dm.org/yahoo/fluxible) | ||
[![devDependency Status](https://img.shields.io/david/dev/yahoo/fluxible.svg)](https://david-dm.org/yahoo/fluxible#info=devDependencies) | ||
@@ -57,9 +57,9 @@ Pluggable, singleton-free container for isomorphic [Flux](https://github.com/facebook/flux) applications. | ||
}, | ||
initialize: function () { // Set the initial state | ||
initialize: () => { // Set the initial state | ||
this.foo = null; | ||
}, | ||
fooHandler: function (payload) { | ||
fooHandler: (payload) => { | ||
this.foo = payload; | ||
}, | ||
getState: function () { | ||
getState: () => { | ||
return { | ||
@@ -78,6 +78,4 @@ foo: this.foo | ||
App = provideContext(connectToStores(App, [FooStore], { | ||
FooStore(store) { | ||
return store.getState(); | ||
} | ||
App = provideContext(connectToStores(App, [FooStore], (stores, props) => { | ||
return stores.FooStore.getState(); | ||
})); | ||
@@ -93,3 +91,3 @@ | ||
const context = app.createContext(); | ||
context.executeAction(action, 'bar', function () { | ||
context.executeAction(action, 'bar', (err) => { | ||
console.log(React.renderToString(context.createElement())); | ||
@@ -96,0 +94,0 @@ }); |
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
79800
998
100