Last active
January 13, 2019 19:05
-
-
Save jsonberry/3cf0de6fc5fd42d27fa35819e24b3b56 to your computer and use it in GitHub Desktop.
rxjs-toolkit examples
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 { 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