1 | import { ActorRef, EmittedFrom } from '.';
|
2 | interface WaitForOptions {
|
3 | /**
|
4 | * How long to wait before rejecting, if no emitted
|
5 | * state satisfies the predicate.
|
6 | *
|
7 | * @default 10_000 (10 seconds)
|
8 | */
|
9 | timeout: number;
|
10 | }
|
11 | /**
|
12 | * Subscribes to an actor ref and waits for its emitted value to satisfy
|
13 | * a predicate, and then resolves with that value.
|
14 | *
|
15 | * @example
|
16 | * ```js
|
17 | * const state = await waitFor(someService, state => {
|
18 | * return state.hasTag('loaded');
|
19 | * });
|
20 | *
|
21 | * state.hasTag('loaded'); // true
|
22 | * ```
|
23 | *
|
24 | * @param actorRef The actor ref to subscribe to
|
25 | * @param predicate Determines if a value matches the condition to wait for
|
26 | * @param options
|
27 | * @returns A promise that eventually resolves to the emitted value
|
28 | * that matches the condition
|
29 | */
|
30 | export declare function waitFor<TActorRef extends ActorRef<any, any>>(actorRef: TActorRef, predicate: (emitted: EmittedFrom<TActorRef>) => boolean, options?: Partial<WaitForOptions>): Promise<EmittedFrom<TActorRef>>;
|
31 | export {};
|
32 | //# sourceMappingURL=waitFor.d.ts.map |
\ | No newline at end of file |