Remove unused asyncId

pull/21833/head
Luke Barnard 2018-02-12 18:37:54 +00:00
parent 7a4c1994c3
commit 3eeef064bf
1 changed files with 8 additions and 11 deletions

View File

@ -33,28 +33,25 @@ limitations under the License.
* `${id}.failure`. * `${id}.failure`.
* *
* The shape of each are: * The shape of each are:
* { action: '${id}.pending', request, asyncId } * { action: '${id}.pending', request }
* { action: '${id}.success', result, asyncId } * { action: '${id}.success', result }
* { action: '${id}.failure', err, asyncId } * { action: '${id}.failure', err }
* *
* where `request` is returned by `pendingFn`, result * where `request` is returned by `pendingFn` and
* is the result of the promise returned by `fn` and * result is the result of the promise returned by
* `asyncId` is a unique ID for each dispatch of the * `fn`.
* asynchronous action.
*/ */
export function asyncAction(id, fn, pendingFn) { export function asyncAction(id, fn, pendingFn) {
return (dispatch) => { return (dispatch) => {
const asyncId = Math.random().toString(16).slice(2, 10);
dispatch({ dispatch({
action: id + '.pending', action: id + '.pending',
request: request:
typeof pendingFn === 'function' ? pendingFn() : undefined, typeof pendingFn === 'function' ? pendingFn() : undefined,
asyncId,
}); });
fn().then((result) => { fn().then((result) => {
dispatch({action: id + '.success', result, asyncId}); dispatch({action: id + '.success', result});
}).catch((err) => { }).catch((err) => {
dispatch({action: id + '.failure', err, asyncId}); dispatch({action: id + '.failure', err});
}); });
}; };
} }