Skip to content

Commit 11650b5

Browse files
committed
docs: add info about accessing api action types
1 parent 23426f4 commit 11650b5

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,32 @@ const duck = createDuck({
624624
});
625625
```
626626

627+
Finally, if you need to access the API action types eg. in `reactions` you can do it quite intuitively in the following way:
628+
629+
> NOTE: since the `types.fetchProfile` is an object we can't access the loading type in the simple way (`types.fetchProfile`), but instead via `types.fetchProfile.loading`.
630+
631+
```js
632+
const duck = createDuck({
633+
// ...
634+
inject: ['user'],
635+
reactions: ({ deps }) => ({
636+
[deps.user.types.fetchProfile.loading]: state => ({
637+
...state,
638+
someField: 1,
639+
}),
640+
[deps.user.types.fetchProfile.success]: state => ({
641+
...state,
642+
someField: 2,
643+
}),
644+
[deps.user.types.fetchProfile.failure]: state => ({
645+
...state,
646+
someField: 3,
647+
}),
648+
}),
649+
// ...
650+
});
651+
```
652+
627653
## API
628654

629655
> TODO: UPDATE API DOCS!

0 commit comments

Comments
 (0)