Created
March 27, 2017 18:41
-
-
Save pemrouz/62e5074ee1104306803148816cada7ac to your computer and use it in GitHub Desktop.
flatmap api?
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
| const o = emitterify() | |
| , stream1 = emitterify() | |
| , stream2 = emitterify() | |
| // without | |
| o.on('primary') | |
| .map(d => console.log(d)) // stream1, stream2 | |
| // with | |
| o.on('primary') | |
| .map(flatten('secondary')) | |
| .map(d => console.log(d)) // 1a, 1a, 2a, 2b | |
| o.emit('primary', stream1) | |
| .emit('primary', stream2) | |
| stream1.emit('secondary', '1a') | |
| stream1.emit('secondary', '1b') | |
| stream2.emit('secondary', '2a') | |
| stream2.emit('secondary', '2b') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment