Last active
August 19, 2016 01:25
-
-
Save dhrrgn/8c874b8b97fa16a437734d23e1fea346 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux'; | |
/** | |
* Combine a set of ReduxModel reducers. | |
* | |
* @param array {models} An array of ReduxModel objects. | |
* @return function A combined redux reducer | |
*/ | |
export function combineModelReducers(models) { | |
let reducers = {}; | |
models.forEach((model) => { | |
reducers[model.name] = model.reducer; | |
}); | |
return combineReducers(reducers); | |
} | |
/** | |
* Initialize a set of ReduxModels | |
* | |
* @param array {models} An array of ReduxModel objects. | |
* @param object {store} A redux store. | |
*/ | |
export function initModels(models, store) { | |
models.forEach((model) => { | |
model.init(store); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment