This release improves type inference for action creators and for entity adapters that are used as reducers, adds warnings if dev check middleware are taking excessive amounts of time, and adds a new selectById
entity selector.
Changes
Type Inference Improvements
Users reported that it was possible to pass an entity adapter update method as a case reducer even if the slice state type didn't match what the update method expected (#434 ). We've updated the TS types to prevent that from being possible.
We've also had a number of cases where users had issues with the typings for action payloads depending on whether strictNullChecks: false
was set. We've altered our action creator types to improve that behavior.
Meanwhile, we've also re-exported the TS types from Reselect for convenience.
Dev Check Middleware Timings
The immutability and serializability dev check middleware both do deep checks of state on every dispatch in dev mode. With a large state tree, this can sometimes noticeably slow down the app, and it's not immediately clear that the dev check middleware are responsible for this.
We've updated both middleware to record how much time is spent actually performing the state checks, and they will now log warning messages if the checks take too long to give you a heads-up that you might want to alter the middleware settings or disable them entirely. The delay is configurable, and defaults to 32ms (two UI frames).
Entity Adapter API Changes
We've added a selectById
selector to createEntityAdapter
for convenience.
We've also removed the map()
update method, which accepted a callback that returned changes to be applied. It couldn't be used as a reducer (the action would be non-serializable), it's easily re-implemented in userland using the updateMany()
update method, and the name map
implied a potentially completely different return type of a non-mutating copy, which is not what it actually did.