Last active
January 9, 2019 03:39
-
-
Save jsonberry/f5a3214e1e6e2e27cc9db13b5882c819 to your computer and use it in GitHub Desktop.
rxjs-toolkit examples
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
import { someApiService } from './some-api.service'; | |
import { propsAreTruthy, ignoreFalsySignals } from 'rxjs-toolkit'; | |
// imagine getSource$ return an object like this: | |
const exampleSource = { | |
id: '123', | |
origin: { | |
name: '', | |
url: 'noop.com', | |
} | |
} | |
// say we only want a Source signal to come through if the name is truthy | |
someApiService.getSource$.pipe( | |
// first check for this prop, if it is falsy, map to false | |
propsAreTruthy('origin.name'), | |
// if the origin name is falsy, we'll ignore the signal entirely | |
// but this still keeps the stream open for the next potential signal to come through | |
ignoreFalsySignals(), | |
).subscribe(signal => this.doSourceThings(signal)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment