-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
41 lines (33 loc) · 1004 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import type { AwaiEvent } from '../core';
import type { BaseConfig } from '../types';
export type Trigger<T> = AwaiEvent<T> | PromiseLike<T> | (() => PromiseLike<T>);
type ShouldExpirePredicate = () => boolean;
export type ExpirationTrigger<T> = AwaiEvent<T> | PromiseLike<T> | ShouldExpirePredicate;
export type Callback<T = never, R = any> = (value: T) => R;
export interface Config extends BaseConfig, Record<string, any> {
repeat?: number;
strategy: 'fork' | 'cyclic' | 'once';
}
export interface FulfilledEvent<T, R> {
event: T;
result: R;
config: Config;
}
export interface SettledEvent<T> {
event?: T;
config: Config;
}
export interface StartedEvent<T> {
event: T;
config: Config;
}
export interface Scenario<T, R, E> {
events: {
fulfilled: AwaiEvent<FulfilledEvent<T, R>>;
rejected: AwaiEvent<unknown>;
settled: AwaiEvent<SettledEvent<E>>;
started: AwaiEvent<StartedEvent<T>>;
};
get config(): Config;
then: AwaiEvent<SettledEvent<E>>['then'];
}