Skip to content

Instantly share code, notes, and snippets.

@bradfordlemley
Created May 30, 2019 14:32
Show Gist options
  • Save bradfordlemley/5dce0f42a80d5a5c34815de1f9158ccc to your computer and use it in GitHub Desktop.
Save bradfordlemley/5dce0f42a80d5a5c34815de1f9158ccc to your computer and use it in GitHub Desktop.
Library-to-Library Interactions with Reactive Programming
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