Last active
December 30, 2018 06:24
-
-
Save artalar/21e507533082e04535b7e66ea01597b7 to your computer and use it in GitHub Desktop.
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
| 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