Last active
January 14, 2019 16:58
-
-
Save jsonberry/b754677814838376fb47692e86e24426 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 { from } from 'rxjs'; | |
import { propsAreTruthy, tapLog } from 'rxjs-toolkit'; | |
const topLevelTruthy = { | |
one: 'I', | |
two: 'am', | |
three: 'truthy', | |
iHaveNestedProps: { // top level also truthy | |
nested: null, | |
}, | |
}; | |
const oneFalsyProp = { | |
one: 'I', | |
am: '', | |
three: 'falsy', | |
}; | |
from([ | |
topLevelTruthy, | |
oneFalsyProp, | |
]).pipe( | |
propsAreTruthy(), | |
/** | |
* by default, all top level properties are checked for truthiness | |
* the first signal will come through as is | |
* all of it's top level props are truthy (one, two, three, iHaveNested) | |
* the next signal has a falsy prop, 'am', it's an empty string | |
* that signal will get mapped to false | |
*/ | |
tapLog(), | |
/** | |
* { one: 'I', two: 'am', three: 'truthy' iHaveNestedProps: { nested: null } } | |
* false | |
*/ | |
).subscribe(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment