Skip to content

Instantly share code, notes, and snippets.

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