Skip to content

Commit 1751eb9

Browse files
authored
Merge pull request #2148 from kyletsang/improve-listener-docs
2 parents 478ffcf + 29c3c37 commit 1751eb9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

docs/api/createListenerMiddleware.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ interface ListenerMiddlewareInstance<
115115
> {
116116
middleware: ListenerMiddleware<State, Dispatch, ExtraArgument>
117117
startListening: (options: AddListenerOptions) => Unsubscribe
118-
stopListening: (options: AddListenerOptions) => boolean
118+
stopListening: (
119+
options: AddListenerOptions & UnsubscribeListenerOptions
120+
) => boolean
119121
clearListeners: () => void
120122
}
121123
```
@@ -172,7 +174,7 @@ type ListenerPredicate<Action extends AnyAction, State> = (
172174
) => boolean
173175

174176
type UnsubscribeListener = (
175-
unsuscribeOptions?: UnsubscribeListenerOptions
177+
unsubscribeOptions?: UnsubscribeListenerOptions
176178
) => void
177179

178180
interface UnsubscribeListenerOptions {
@@ -351,7 +353,7 @@ export interface ListenerEffectAPI<
351353
*/
352354
signal: AbortSignal
353355
/**
354-
* Returns a promise resolves after `timeoutMs` or
356+
* Returns a promise that resolves after `timeoutMs` or
355357
* rejects if the listener has been cancelled or is completed.
356358
*/
357359
delay(timeoutMs: number): Promise<void>
@@ -648,7 +650,7 @@ listenerMiddleware.startListening({
648650
649651
### Complex Async Workflows
650652
651-
The provided async workflow primitives (`cancelActiveListeners`, `unsuscribe`, `subscribe`, `take`, `condition`, `pause`, `delay`) can be used to implement behavior that is equivalent to many of the more complex async workflow capabilities found in the Redux-Saga library. This includes effects such as `throttle`, `debounce`, `takeLatest`, `takeLeading`, and `fork/join`. Some examples from the test suite:
653+
The provided async workflow primitives (`cancelActiveListeners`, `unsubscribe`, `subscribe`, `take`, `condition`, `pause`, `delay`) can be used to implement behavior that is equivalent to many of the more complex async workflow capabilities found in the Redux-Saga library. This includes effects such as `throttle`, `debounce`, `takeLatest`, `takeLeading`, and `fork/join`. Some examples from the test suite:
652654
653655
```js
654656
test('debounce / takeLatest', async () => {

packages/toolkit/src/listenerMiddleware/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export interface ForkedTaskAPI {
5858
*/
5959
pause<W>(waitFor: Promise<W>): Promise<W>
6060
/**
61-
* Returns a promise resolves after `timeoutMs` or
61+
* Returns a promise that resolves after `timeoutMs` or
6262
* rejects if the task or the parent listener has been cancelled or is completed.
6363
* @param timeoutMs
6464
*/
@@ -231,7 +231,7 @@ export interface ListenerEffectAPI<
231231
*/
232232
signal: AbortSignal
233233
/**
234-
* Returns a promise resolves after `timeoutMs` or
234+
* Returns a promise that resolves after `timeoutMs` or
235235
* rejects if the listener has been cancelled or is completed.
236236
*/
237237
delay(timeoutMs: number): Promise<void>
@@ -373,7 +373,7 @@ export interface UnsubscribeListenerOptions {
373373

374374
/** @public */
375375
export type UnsubscribeListener = (
376-
unsuscribeOptions?: UnsubscribeListenerOptions
376+
unsubscribeOptions?: UnsubscribeListenerOptions
377377
) => void
378378

379379
/**

0 commit comments

Comments
 (0)