-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
27 lines (23 loc) · 914 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
import type { MessageQueue } from "@watchable/queue";
/** Function to process a queue of values including an initial starting value, leading to
* a final `Ending` result.
*/
export type QueueHandler<Selected, Ending> = (
valueQueue: MessageQueue<Selected>,
initialValue: Selected
) => Promise<Ending>;
/** A function to notify a series of changing values from a store. */
export type Follower<Selected, Ending> = (
selected: Selected,
controlHandle: Controls<Selected, Ending>
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
) => Promise<void | ExitStatus>;
/** A control object for a {@link Follower} function to signal
* exit behaviour, retrieve references.
*/
export interface Controls<Selected, Ending> {
lastSelected: () => Selected | undefined;
exit: (ending: Ending) => ExitStatus;
}
/** A type used as a special return value. */
export type ExitStatus = ["exit"];