Created
May 30, 2019 14:32
-
-
Save bradfordlemley/5dce0f42a80d5a5c34815de1f9158ccc to your computer and use it in GitHub Desktop.
Library-to-Library Interactions with Reactive Programming
This file contains 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 { from } from 'rxjs'; | |
import { distinctUntilKeyChanged } from 'rxjs/operators'; | |
const todoLib = createTodoLib(); | |
const authLib = createAuthLib(); | |
from(todoLib.state$).pipe( | |
distinctUntilKeyChanged('authFailed'), | |
filter(state => state.authFailed), | |
).subscribe( | |
() => authLib.refreshAuth() | |
); | |
from(authLib.state$).pipe( | |
distinctUntilKeyChanged('user'), | |
).subscribe( | |
authState => todoLib.setUser(authState.user) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment