UNPKG

1.24 kBJavaScriptView Raw
1// import {transport} from './utils/transport.js';
2// require('babel-polyfill');
3//
4//
5// // Use currying to reduce size of the parameters?
6// // If so how do people not familiar with currying work around this
7// // store or dispatch?
8//
9//
10//
11// export function reachWithOpts (path, query, queryParams = {}, store, actionCreator, retry) {
12// 1. store.getState(propertyToChange)
13// 2. store.dispatch(actionCreator())
14// 3. return async dispatch => {
15// try{
16// 4. let response = await transport(path, query, queryParams, retry);
17// 5. } catch(error) {
18// try{
19// let response = await transport(path, query, queryParams)
20// 6. } catch(error) {
21// dispatch(actionCreator(1));
22// 7. console.log(error);
23// }
24// }
25// }
26// }
27//
28
29//1. getState of the current property value you are going to act upon
30//2. dispatch synchronous function to update client
31//3. return asynchronous function with dispatch to send payload to server
32//4. transport and dispatch actioncreator with response
33//5. if error catch and the error and try transport again.
34//6. setstate to previous value
35//7. if error return the error to client with failure message