Skip to content

Commit ef42f4b

Browse files
committed
Release 1.4.0
Features: * updated `WatchedController` type to be able to map changed action names in more convenient way; * updated `Action` type, now method `addNextAction` returns action instance to be able to pass action chain right after extending in one line to the dispatch function;
1 parent 50b1268 commit ef42f4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1519
-6955
lines changed

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Changelog
22

3+
### 1.4.0
4+
5+
Features:
6+
* updated `WatchedController` type to be able to map changed action names in more convenient way:
7+
```ts
8+
@watch
9+
export class UserController extends ControllerBase<State> {
10+
@watch('loadChatById') loadChatByIdFromSpecialStorage(action: Action<{ chatId: string }>) {/* ... */}
11+
}
12+
13+
const typedController = (UserController as unknown) as WatchedController<UserController, {
14+
loadChatByIdFromSpecialStorage: 'loadChatById', // map original method name to the new one
15+
}>;
16+
export { typedController as UserController };
17+
```
18+
* updated `Action` type, now method `addNextAction` returns action instance to be able to pass action chain right after extending in one line to the dispatch function:
19+
before:
20+
```ts
21+
interface Action<Payload = undefined> extends AnyAction {
22+
// ...
23+
addNextActions(...actions: (Action<any> | ActionFactory)[]): void;
24+
}
25+
```
26+
after:
27+
```ts
28+
interface Action<Payload = undefined> extends AnyAction {
29+
// ...
30+
addNextActions(...actions: (Action<any> | ActionFactory)[]): Action<Payload>;
31+
}
32+
```
33+
334
### 1.3.0
435

536
BREAKING CHANGES:

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,29 +147,23 @@ That's it!
147147
#### <a name="usage"></a> Custom action names
148148

149149
You can use custom action name, like `@watch('myCustomActionName')`.
150-
But in this case you should change definition of such method with `DecoratedWatchedController`
150+
In this case you should to pass name mapper type as second argument of `WatchedController`
151151

152152
```ts
153-
import { ControllerBase, watch, DecoratedWatchedController } from '@tomas_light/react-redux-controller';
153+
import { ControllerBase, watch, WatchedController } from '@tomas_light/react-redux-controller';
154154
import { State } from "./State";
155155

156156
@watch
157157
export class UserController extends ControllerBase<State> {
158158
/* ... */
159159

160160
@watch loadUser(action: Action<{ userID: string }>) {/* ... */}
161-
@watch('loadChatInfo') loadCurrentUser(action: Action<{ chat: boolean }>) {/* ... */}
161+
@watch('loadChatById') loadChatByIdFromSpecialStorage(action: Action<{ chatId: string }>) {/* ... */}
162162
}
163163

164-
type Controller =
165-
// keep infered type for all actions except action with custom action type
166-
Omit<WatchedController<UserController>, 'loadCurrentUser'>
167-
// specify type for custom action
168-
& DecoratedWatchedController<[
169-
['loadChatInfo', { userID: string; }]
170-
]>;
171-
172-
const typedController = (UserController as unknown) as Controller;
164+
const typedController = (UserController as unknown) as WatchedController<UserController, {
165+
loadChatByIdFromSpecialStorage: 'loadChatById', // map original method name to the new one
166+
}>;
173167
export { typedController as UserController };
174168
```
175169

coverage/clover.xml

Lines changed: 0 additions & 338 deletions
This file was deleted.

coverage/coverage-final.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

coverage/lcov-report/Middleware.ts.html

Lines changed: 0 additions & 148 deletions
This file was deleted.

0 commit comments

Comments
 (0)