Skip to content

Instantly share code, notes, and snippets.

@jsonberry
Last active January 13, 2019 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsonberry/3cf0de6fc5fd42d27fa35819e24b3b56 to your computer and use it in GitHub Desktop.
Save jsonberry/3cf0de6fc5fd42d27fa35819e24b3b56 to your computer and use it in GitHub Desktop.
rxjs-toolkit examples
import { of } from 'rxjs';
import { propsAreTruthy, tapLog } from 'rxjs-toolkit';
const source$ = of({
foo: {
bar: {
baz: 'truthy!',
},
},
zap: {
zing: false,
},
ping: true
});
source$.pipe(
propsAreTruthy(
'foo.bar.baz', // "baz: 'truthy'" will pass!
'ping', // "ping: true" will pass!
'zap.zing', // "zing: false" Fail, zing is not truthy, map signal to false
'rxjs.toolkit', // this path doesn't exist, it would also trigger the map to false
),
tapLog(), // false
).subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment