Fluent syntax for defining typesafe reducers on top of typescript-fsa.
undefined
as the first argument to reducers produced by reducerWithoutInitialState
no longer typechecks (unless undefined
is a subtype of their state). Thanks @sgrishchenko!.withHandling()
method for adding reusable sequences of updates in fluent style.ReducerBuilder
type signature so the output type parameter is optional if it is the same as the input.The API of this library hasn't changed for some time, and it has seen extensive production use since the last release. The time has come to announce 1.0.0 and commit to stability.
typescript-fsa
is now a peer dependency instead of a hard dependency. This will avoid situations where the dependency would be duplicated due to version differences but could cause you problems if you were relying on typescript-fsa-reducers
to pull in typescript-fsa
for you. To resolve this, make sure to install typescript-fsa
as a separate dependency:
yarn add typescript-fsa
Type definition of reducers created by builders now accepts undefined
as its first argument (the state), which causes the initial state to be used. This functionality was always present, but "hidden" by the type definition. This change matches an equivalent one in the Redux type definitions seen here.
Thanks to @amc6 for the contribution!
Sourcemaps are now included.
Reducer chains are now mutable, meaning that reducer.case()
modifies the callee rather than returning a new instance. To produce immutable reducers, a new .build()
method is introduced. This is in line with a typical builder pattern.
For discussion on the change, see https://github.com/dphilipson/typescript-fsa-reducers/issues/7.
.build()
method for producing an immutable reducer as a plain function..caseWithAction()
method for adding handlers which receive the whole action rather than just the payload.Thanks very much to @autoric for the ideas behind this release.