Methods
allSettled(unit, {scope, params?})
Calls the provided unit within the current scope and wait for all triggered effects to complete.
Formulae
allSettled<T>(unit: Event<T>, {scope: Scope, params?: T}): Promise<void>
allSettled<T>(unit: Effect<T, Done, Fail>, {scope: Scope, params?: T}): Promise<
| {status: 'done'; value: Done}
| {status: 'fail'; value: Fail}
>
allSettled<T>(unit: Store<T>, {scope: Scope, params?: T}): Promise<void>
Arguments
since
Return value for effect is supported since effector 21.4.0
Examples
Contribution
TBD
Please, open PullRequest and contribute examples for this section via “Edit this page” link below.
allSettled(scope)
Checks the provided scope for any ongoing computations and wait for their completion.
Formulae
allSettled<T>(scope): Promise<void>
Arguments
scope
: Scope
since
Supported since effector 22.5.0
Examples
Usage in tests
For example, tests that validate the integration with an external reactive API
test('integration with externalSource', async () => {
const scope = fork()
const updated = createEvent()
sample({
clock: updated,
target: someOtherLogicStart,
})
// 1. Subscribe event to external source
const externalUpdated = scopeBind(updated, {scope})
externalSource.listen(() => externalUpdates())
// 2. Trigger update of external source
externalSource.trigger()
// 3. Wait for all triggered computations in effector's scope, even though these were not triggered by effector itself
await allSettled(scope)
// 4. Check anything as usual
expect(...).toBe(...)
})