Skip to content

Commit b8308ec

Browse files
emmenkoacdlite
authored andcommitted
More JSDoc
1 parent d816847 commit b8308ec

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/utils/composeMiddleware.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
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+
*/
17
export default function composeMiddleware(...middlewares) {
28
return middlewares.reduceRight((composed, m) => m(composed));
39
}

src/utils/composeStores.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import mapValues from '../utils/mapValues';
22
import pick from '../utils/pick';
33

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+
*/
414
export default function composeStores(stores) {
515
const finalStores = pick(stores, (val) => typeof val === 'function');
616
return function Composition(atom = {}, action) {

0 commit comments

Comments
 (0)