Files: a765975715b21c6b6d64958016861a6a86d0d52e / app / util / fetch-all-data.js
679 bytesRaw
1 | // https://github.com/jlongster/react-redux-universal-hot-example/blob/master/src/helpers/fetchAllData.js |
2 | |
3 | import Promise from 'pinkie-promise' |
4 | |
5 | export default function fetchAllData(components, getState, dispatch, location, params) { |
6 | const fetchers = components |
7 | .filter((component) => !!component) // Weed out 'undefined' routes |
8 | .filter((component) => component.fetchData) // only look at ones with a static fetchData() |
9 | .map((component) => component.fetchData) // pull out fetch data methods |
10 | .map(fetchData => { |
11 | return fetchData(getState, dispatch, location, params) |
12 | }) // call fetch data methods and return promises |
13 | |
14 | return Promise.all(fetchers) |
15 | } |
16 |
Built with git-ssb-web