Created
October 29, 2016 20:11
-
-
Save ujeenator/7a795e1ceb6602a7d940536a0ce72e02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import delay from 'delay'; | |
| async function fooActionCreator(){ | |
| try { | |
| const result = await Promise.race([ | |
| fetch('/data', {cancellation}), | |
| delay(10000).then(() => throw 'CANCELLED'), | |
| ]); | |
| return {type: 'REQUEST_DONE', result}; | |
| } catch(ex) { | |
| if (ex === CANCELLED) { | |
| return {type: 'REQUEST_CANCELLED'}; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment