Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created May 2, 2017 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briancavalier/646792d8322c99d235d47a364b37960f to your computer and use it in GitHub Desktop.
Save briancavalier/646792d8322c99d235d47a364b37960f to your computer and use it in GitHub Desktop.
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