Skip to content

Releases: cyclejs-community/redux-cycles

0.4.0

28 Feb 23:29
Compare
Choose a tag to compare

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()
})

v0.3.0

13 Feb 22:49
Compare
Choose a tag to compare

BREAKING CHANGES

  • createCycleMiddleware() no longer takes any arguments. Instead you need to call Cycle.run yourself (which can be installed via npm i -s @cycle/xstream-run) passing it your main function and drivers explicitly:
+import {run} from '@cycle/xstream-run';

-const cycleMiddleware = createCycleMiddleware(main, drivers);
+const cycleMiddleware = createCycleMiddleware();
+const { makeActionDriver, makeStateDriver } = cycleMiddleware;

const store = createStore(
  rootReducer,
  applyMiddleware(cycleMiddleware)
);

+run(main, {
+  ACTION: makeActionDriver(),
+  STATE: makeStateDriver()
+})

createCycleMiddleware() apart from returning the middleware function, also has two function properties attached to it; namely the makeActionDriver() and the makeStateDriver() which you can use accordingly when you call Cycle.run.