Releases: tomas-light/redux-controller-middleware
Releases · tomas-light/redux-controller-middleware
3.1.0
🚧 Breaking changes:
- 🔨 removed all methods from actions to achieve serialization clearance and avoid redux warning
- instead of
action.stop()
usestopAction(action)
- instead of
action.addNextActions(action2)
usechainActions(action, action2)
- instead of
action.executionCompleted = ...
usewaitAction
(see bellow) - initial value of storeSlice is plain object now
- instead of
- 🐛🔨
createReducer
payload type is corrected
🚀 Features:
waitAction
- you can wait action execution with promise syntax
const dispatch = useDispatch();
await waitAction(MyController.fetchUsers(), dispatch);
- add helpers for test
getStoreSliceUpdateActionType
- helps you to extract an action type of store slice update methodmakeActionType
- helps you create an action type with passed parameters to compare an action type in your tests with expected valuemockMiddlewareForTests
- helps you mock middleware and state, dispatch actions and analyze the process
🔨 Tech fixes:
- updated redux dependencies
- redux to 5.0.1
- @reduxjs/toolkit to 2.1.0
- react-redux to 9.1.0
makeActionType
function is exportedisAction
changed conditions of action determination (removed methods, and added actiontype
)
3.0.0
🚧 Breaking changes
@watch
decorator was splat into two decorators@controller
and@reducer
- ControllerBase generic now accepts two parameters, and
State
moved to the second one createReducer
function renamed tocreateStoreSliceReducer
- updated Action type related to updates in redux
- changed order of
next
call in middleware - now it calls firstly, and action will be processed after it - change action type
🚀 Features:
- ControllerBase now has
updateStoreSlice
protected method to reduce boilerplate code in you inherited classes - added storeSlice decorator, that you can use instead of creating static properties in your store slice class
- added
updateStoreSlice
function to create action for store slice updating - added
getReducersFromStoreSlices
function to get reducers from new store slices syntax - added ability to wait till store will be updated by
await this.updateStoreSlice(...)
in controller - added
createReducer
function to create one-action reducer (functional style) - updated redux to 5.0.0
- updated typescript to 5.3.3
- updated cheap-di to 4.0.1
Release 2.0.0-rc.2
🚀 add support for async callbacks in actions chain
Release 2.0.0-rc.1
🐛 Fixed issue when next actions are not handled by other middlewares
🔨 Improved code flow, simplify statements, reduce code complexity
Release 1.5.4
Feature:
- 🚀 add
InferState
type
Release 1.5.3
Bugfixes:
- 🐛Fix error Action<{ data: MyData; }>' is not assignable to parameter of type 'Action'. Changed
dispatch
type inMiddleware
fromAction
toAction<any>
.
Release 1.5.0
Breaking changes:
- package renamed from
@tomas_light/react-redux-controller
toredux-controller-middleware
; Reducer
function renamed tocreateReducer
;- Enabled strict null checks in tsconfig.
Updated documentation:
- added examples;
- described action chaining.
Release 1.4.0
Features:
- updated
WatchedController
type to be able to map changed action names in more convenient way:
@watch
export class UserController extends ControllerBase<State> {
@watch('loadChatById') loadChatByIdFromSpecialStorage(action: Action<{ chatId: string }>) {/* ... */}
}
const typedController = (UserController as unknown) as WatchedController<UserController, {
loadChatByIdFromSpecialStorage: 'loadChatById', // map original method name to the new one
}>;
export { typedController as UserController };
- updated
Action
type, now methodaddNextAction
returns action instance to be able to pass action chain right after extending in one line to the dispatch function:
before:
interface Action<Payload = undefined> extends AnyAction {
// ...
addNextActions(...actions: (Action<any> | ActionFactory)[]): void;
}
after:
interface Action<Payload = undefined> extends AnyAction {
// ...
addNextActions(...actions: (Action<any> | ActionFactory)[]): Action<Payload>;
}