Created
May 2, 2017 01:35
-
-
Save briancavalier/646792d8322c99d235d47a364b37960f to your computer and use it in GitHub Desktop.
This file contains 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 { tap, take, skip, concat, fromArray, runEffects } from '../packages/core/src/index' | |
import { newDefaultScheduler } from '../packages/scheduler/src/index' | |
import { EventEmitter } from 'events' | |
import multicastStream from '@most/multicast' | |
import { fromEvent } from 'most' | |
const emitter = new EventEmitter() | |
const scheduler = newDefaultScheduler() | |
const observe = (f, stream) => runEffects(tap(f, stream), scheduler) | |
const multicast = (stream) => multicastStream(stream).source | |
const stream = multicast(fromEvent('event', emitter)) | |
const result = concat(take(1, stream), skip(1, stream)) | |
observe(console.log, result) | |
for ( let i = 1; i <= 5; i++ ) | |
emitter.emit( 'event', i ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment