-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Evt.create.ts
22 lines (20 loc) 路 852 Bytes
/
Evt.create.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { importProxy } from "./importProxy.ts";
import type { Evt, StatefulEvt, NonPostableEvtLike, UnpackEvt } from "./types/index.ts";
export function create<E extends NonPostableEvtLike<any> | undefined = NonPostableEvtLike<void>>(): Evt<UnpackEvt<E>>;
/**
* https://docs.evt.land/api/evt/create
* Return a new Evt<T> instance.
*/
export function create<T>(): Evt<T>;
/**
* https://docs.evt.land/api/evt/create
* Return a new StatefulEvt<T> instance.
*/
export function create<T>(initialState: T ): StatefulEvt<T>;
export function create<E extends NonPostableEvtLike<any> | undefined>(initialState: UnpackEvt<E> ): StatefulEvt<UnpackEvt<E>>;
export function create(...args: [] | [any] ): Evt<any> | StatefulEvt<any> {
return args.length === 0 ?
new importProxy.Evt() :
new importProxy.StatefulEvt(args[0])
;
}