All notable changes to this project will be documented in this file.
- All executed sagas via
saga(function * (logic) { doStuff() })
and similar functions now getlogic
as their first argument.
- Fix
package.json
import config.
- Add TypeGen support for
workers
- Support Kea 3.0, introduce builders
saga
,workers
,takeEvery
,takeLatest
andcancelled
-
The option
{ useLegacyUnboundActions: false }
when installing the plugin now defaults tofalse
. See the discussion about this parameter in the changelog for version 1.0.0 below. This option will be completely removed in kea-saga versions 3.0 and later. -
You may now use action without
[actions.
and]
intakeLatest
andtakeEvery
. For example:
kea({
actions: () => ({
doSomething: true,
otherAction: true,
}),
})
takeEvery: ({ actions }) => ({
doSomething: function* () {
// saga code here - no need for `[actions.]` around `doSomething`
},
[actions.otherAction]: function* () {
// saga code here the old way
},
})
1.0.0 had some bugs, please use 1.0.1 instead.
-
Support for Kea 1.0
-
Added the option
{ useLegacyUnboundActions: true }
to the plugin. It defaults totrue
and when enabled will not bind your actions todispatch
, unlike everywhere else in Kea. This may cause some issues, but it is a necessary step if you're migrating from 0.28.
Since Kea 1.0 all actions
on a logic are automatically bound to dispatch. This was not the case with 0.28 and earlier, where actions
just returned action creators without dispatching them. The previous action creators are now accessible via logic.actionCreators
.
This means calling someLogic.actions.doSomething()
will automatically dispatch the action, instead of just returning the an object in the format { type: 'do something', payload: {} }
. You can still get that object now by using someLogic.actionCreators.doSomething()
.
In this useLegacyUnboundActions
mode, the actions inside a logic are not bound when used by redux-saga functions (takeEvery, takeLatest, start, stop, workers). However if you manually import some other logic and then access otherLogic.actions.doSomething
, those action will be bound to dispatch. Placing them inside a yield put(otherLogic.actions.doSomething())
will fire the action twice!
To get around this, either skip yield put()
with those actions... or use otherLogic.actionCreators.doSomething
instead.
Doing something like yield take(otherLogic.actions.doSomething().type)
will obviously also fire that action instead of waiting for it. Use yield take(otherLogic.actions.doSomething)
instead.
This means that the following situation can happen:
takeEvery: ({ actions }) => ({
[actions.someAction]: function* () {
// this will be dispatched just once, as actions are not
// bound when accessing from the `actions` object given to `takeEvery`
// or from `this.actions`
yield put(actions.something())
// this will however be dispatched twice!
yield put(otherLogic.actions.something())
// this will work as expected
yield put(otherLogic.actionCreators.something())
},
})
For now when you add the saga plugin to kea, the parameter useLegacyUnboundActions
will be set to true.
In case you use { useLegacyUnboundActions: false }
when initialising the plugin, all actions will be bound
to dispatch
, including the ones in takeEvery: ({ actions }) => {}
, etc.
The option useLegacyUnboundActions
will default to false
in the next breaking release (2.0). If you're
starting a new app with kea-saga
already now, feel free to set it to false yourself.
- Keep better track of started and stopped sagas so that we don't unmount before all are disconnected
- Selectors accessed via
yield this.get('something')
now have access to the wrapped Component's props
- Updated to the plugin system of kea 0.27
- You must now install the plugin manually or import from
kea-saga/install
. See the README for details. - Export
workers
in the logic store
- Updated to the plugin system of kea 0.26
- First version