You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -652,6 +652,31 @@ const model = createModel({
652
652
});
653
653
```
654
654
655
+
The default behaviour for `fetchable.success` reducer is to always replace the whole `data` field with the action's payload, so under the hood the updater function is the following:
656
+
657
+
```js
658
+
constupdater= (data, action) =>action.payload;
659
+
```
660
+
661
+
However, often you don't simply want to replace the data field but insted merge it with the payload somehow. For these use cases it is possible to pass an updater function to the fetchable action as the third parameter. Note that you don't need to pass the reducer definition object if you don't need it - a simple `null` is just fine.
In some cases your actions don't need to update the state in any way and you might just want to listen to the action in your sagas. For these cases Reducktion also provides a helper function `fetchable.noop()` that returns a no-op reducer so the action won't update the state but you can still the action type when setuping your saga watchers.
656
681
657
682
If you need to access the fetchable action types also in your `reactions` you can do it in the following way:
0 commit comments