All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- improved typings. Now can specify model as generic:
RematchDispatch<RootModel>
(@777PolarFox777) - improved inferred typings (@777PolarFox777)
- typings improvements for models
- update dependencies & examples
- set plugins to use MIT license
- update dependencies & examples
- fix issue on IE11
- setup TypeScript tests & Travis CI builds
- 6 mint leaves, 3/4oz simple syrup, 3/4oz lime juice, 1oz rum, 2oz club soda. Happy 1.0!
- added
model.baseReducer
for using normal redux reducers within a model #450. Additionalmodel.reducers
run after the baseReducer to produce the final state. See model.baseReducer for details.
- removed
dispatch
&getState
imports. See #446. Instead it is recommended to use:
import { init } from '@rematch/core'
const store = init()
export const { getState, dispatch } = store
export default store
- plugin
onStoreCreated
can now return an object, that will merge into the return value ofinit
. See #443.
- Option to disable devtools 9a17312
- Improved typings
- Option to name a store on init 6c69529
- Access to config inside of plugins for plugin development
- fix to ensure lazy loaded stores will update 9a44865
- typings fixes
- support TS strict null types
- fix select plugin typings
- resolve issue with rootState in effects
- Use a function as your "effects" to access local
dispatch
{
effects: dispatch => ({
async someEffect() {
dispatch.someModel.someAction()
},
})
}
- TS typings improvements:
- Use
createModel
with TS models - Use
getSelect
with TS select - See TS example for details
- Use
- much improved TS typings, now with dispatch autocomplete
- improved TS typings
- use store names in redux devtools
- plugin API has changed to avoid using
init
. Shared dependencies are accessed withthis
. See the plugins API - as a result of plugin API changes, v1.0.0-alpha.0 requires updating all plugins
- imported global
dispatch
now fires into all stores - imported global
getState
now gets state from all stores. Note:init({ name })
will be used as the store.name, otherwise it defaults to the index.
Effects now dispatch actions that can be seen in the devtools.
Support for devtool action creators. See #281.
- listen to actions from other models within your reducers
const count2 = {
state: 0,
reducers: {
// listens for action from other reducer
'count1/increment': state => state + 1,
},
}
Note: not yet available for effects.
getState
from core in 0.4.0 will be altered with v1.0.0.
- export
getState
from core. See example below:
import { getState } from '@rematch/core'
const state = getState()
- dispatch meta parameter - an optional second dispatch param that can be used to pass "meta" information
dispatch.example.update(payload, { syncWithServer: true })
// is equal to:
// dispatch({ type: 'example/update', payload, meta: { syncWithServer} })
Meta can be accessed as the third param from reducers and effects.
const model = {
state: 0,
reducers: {
someReducer: (state, payload, meta) {
// see meta as third param
}
}
}
- a dispatch will return a value as a Promise
- Overwrite store.dispatch with rematch dispatch. No more need for importing dispatch when using "react-redux".