Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
rxjs-toolkit examples
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
You can’t perform that action at this time.