Skip to content

0.4.0

Latest
Compare
Choose a tag to compare
@lmatteis lmatteis released this 28 Feb 23:29
· 7 commits to master since this release

This release adds support for multiple stream libraries #33.

You can simply import @cycle/<stream-lib>-run and use the stream library in your main code.

For instance to use RxJS rather than xstream, simply install @cycle/rxjs-run along with rxjs and then in your code:

import {run} from '@cycle/rxjs-run'

function main(sources) {
  const pong$ = sources.ACTION
    .filter(action => action.type === 'PING')
    .do(_ => _) // do() only exists in RxJS
    .mapTo({ type: 'PONG' })

  return {
    ACTION: pong$
  }
}

const cycleMiddleware = createCycleMiddleware()
const { makeActionDriver, makeStateDriver } = cycleMiddleware
const store = createStore(
  rootReducer,
  applyMiddleware(cycleMiddleware)
)

// Here run is from rxjs, not xstream
run(main, {
  ACTION: makeActionDriver(),
  STATE: makeStateDriver()
})