Skip to content

Instantly share code, notes, and snippets.

@artalar
Last active December 30, 2018 06:24
Show Gist options
  • Select an option

  • Save artalar/21e507533082e04535b7e66ea01597b7 to your computer and use it in GitHub Desktop.

Select an option

Save artalar/21e507533082e04535b7e66ea01597b7 to your computer and use it in GitHub Desktop.
firstName$ = createCaller()
lastName$ = createCaller()
// not lazy
fullName$ = combine(
[firstName$, lastName$],
(_, fn, ln) => [fn, ln].join(' ')
);
displayName$ = combine(
[firstName$, fullName$],
(_, firstN, fullN) => firstN.length < 10 ? fullN : firstN
);
// lazy
isNameHuge = combine([firstName$], (_, fn) => fn.length > 10)
fullName$ = combine(
[isNameHuge$, firstName$, lastName$],
(_, lazy, firstName, lastName) => !lazy && [firstName, lastName].join(' ')
);
displayName$ = combine(
[isNameHuge$, firstName$, fullName$],
(_, isNameHuge, firstName, lastName) => isNameHuge ? firstName : lastName
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment