File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Given a list of middlewares, compose them from left to right.
3
+ *
4
+ * @param {Array } middlewares - a list of middleware functions
5
+ * @return {Function } the combined middleware function
6
+ */
1
7
export default function composeMiddleware ( ...middlewares ) {
2
8
return middlewares . reduceRight ( ( composed , m ) => m ( composed ) ) ;
3
9
}
Original file line number Diff line number Diff line change 1
1
import mapValues from '../utils/mapValues' ;
2
2
import pick from '../utils/pick' ;
3
3
4
+ /**
5
+ * Given a list of stores, maps the state keys to reducer functions.
6
+ * The composed store, when invoked, will internally map all the
7
+ * results of the computed stores (being effectively the state).
8
+ * When the store function is invoked again, it will pass the
9
+ * existing state value as initial state.
10
+ *
11
+ * @param {Object } stores - an object with the store reducer functions
12
+ * @return {Function } the composed store function
13
+ */
4
14
export default function composeStores ( stores ) {
5
15
const finalStores = pick ( stores , ( val ) => typeof val === 'function' ) ;
6
16
return function Composition ( atom = { } , action ) {
You can’t perform that action at this time.
0 commit comments