Created
May 10, 2016 04:37
-
-
Save camwest/66b19208ac3c7c4d7c44f5de276d680e 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* watchEvents(): any { | |
| const initial = yield call(ExternalApi.getCurrent); | |
| yield put(receiveEvent(initial); | |
| const chan = yield call(setupEvents); | |
| while (true) { | |
| const event = yield take(chan); | |
| yield put(receiveEvent(event)); | |
| } | |
| } | |
| function setupEvents() { | |
| return eventChannel(listener => { | |
| ExternalApi.addChangeListener(listener); | |
| return () => { | |
| ExternalApi.removeChangeListener(listener); | |
| } | |
| }); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment