git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 96cd501395a5a7184948ba07a7ea02a05ae9f23a

Files: 96cd501395a5a7184948ba07a7ea02a05ae9f23a / 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
3import Promise from 'pinkie-promise'
4
5export 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