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: packages/action-listener-middleware/README.md
+24-8Lines changed: 24 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ Current options are:
114
114
115
115
-`onError`: an optional error handler that gets called with synchronous and async errors raised by `listener` and synchronous errors thrown by `predicate`.
Statically adds a new listener callback to the middleware.
120
120
@@ -166,6 +166,7 @@ middleware.addListener({
166
166
})
167
167
```
168
168
169
+
It throws error if listener is not a function.
169
170
The ["matcher" utility functions included in RTK](https://redux-toolkit.js.org/api/matching-utilities) are acceptable as predicates.
170
171
171
172
The return value is a standard `unsubscribe()` callback that will remove this listener. If you try to add a listener entry but another entry with this exact function reference already exists, no new entry will be added, and the existing `unsubscribe` method will be returned.
@@ -174,20 +175,33 @@ The `listener` callback will receive the current action as its first argument, a
174
175
175
176
All listener predicates and callbacks are checked _after_ the root reducer has already processed the action and updated the state. The `listenerApi.getOriginalState()` method can be used to get the state value that existed before the action that triggered this listener was processed.
Removes a given listener. Accepts the same arguments as `middleware.addListener()` and throws error if listener is not a function.
181
+
Returns `true` if the `options.listener` listener has been removed, `false` if no subscription matching the input provided has been found.
180
182
181
-
-`typeOrActionCreator: string | ActionCreator`: the same action type / action creator that was used to add the listener
182
-
-`listener: ListenerCallback`: the same listener callback reference that was added originally
183
-
184
-
Note that matcher-based listeners currently cannot be removed with this approach - you must use the `unsubscribe()` callback that was returned when adding the listener.
A standard RTK action creator that tells the middleware to dynamically add a new listener at runtime. It accepts exactly the same options as `middleware.addListener()`
189
202
190
203
Dispatching this action returns an `unsubscribe()` callback from `dispatch`.
204
+
It throws error if listener is not a function.
191
205
192
206
```js
193
207
// Per above, provide `predicate` or any of the other comparison options
0 commit comments