Last active
July 24, 2019 00:24
-
-
Save evan-brass/53ac9f02fe29d391b96b0f575a6cf68a 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
| function* testHelper() { | |
| console.log('Entering Helper'); | |
| yield delay(1000); // State H-1 | |
| console.log('Helper: Transition 1'); | |
| yield delay(1000); // State H-2 | |
| console.log('Helper: Transition 2'); | |
| return 5; | |
| } | |
| function* test() { | |
| try { | |
| console.log('About to call testHelper'); | |
| const value = yield* testHelper(); // State T-1 | |
| console.log(`Got ${value} from testHelper`); | |
| } finally { | |
| console.log('starting the finally'); | |
| yield delay(1000); // State T-2 | |
| console.log('finishing the finally'); | |
| } | |
| return 'success'; | |
| } | |
| const a = cancelable(test()); | |
| a.then(result => console.log('cancelable resolved with', result)); | |
| // a.cancel() to cancel the machine at any time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment