Created
November 4, 2016 17:04
-
-
Save steida/344d994f992fdb27940ce55094bbbfdc 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
| // TODO: Run epic on app start if geolocation was already explicitly requested. | |
| const watchAppPositionEpic = (action$, { geolocation }) => { | |
| const geolocation$ = Observable.create(observer => { | |
| const onNext = (position: Position) => { | |
| const action = watchAppPositionNext(geopositionToObject(position)); | |
| observer.next(action); | |
| }; | |
| const onError = ({ code, message }: PositionError) => { | |
| const action = watchAppPositionFail({ code, message }); | |
| observer.next(action); | |
| }; | |
| const watchID = geolocation.watchPosition(onNext, onError); | |
| return () => { | |
| geolocation.clearWatch(watchID); | |
| }; | |
| }); | |
| return action$.ofType(WATCH_APP_POSITION) | |
| .switchMap(() => | |
| geolocation$.takeUntil(action$.ofType(APP_STOP)) | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment