Last active
September 13, 2025 12:13
-
-
Save slorber/7ae19043ffb43d60ff17 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* runTimer(getState) { | |
| while(yield take('START')) { | |
| while(true) { | |
| const {stop, tick} = yield race({ | |
| stop : take('STOP'), | |
| tick : call(wait, ONE_SECOND); | |
| }) | |
| if ( !stop ) { | |
| yield put(actions.tick()); | |
| } else { | |
| break; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like @mrsoto's suggestion. A little one-liner is more readable: