-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
42 lines (33 loc) · 1.07 KB
/
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
42
export type UUID = string
export interface Reactive<T> {
value: T | undefined
subscribe: (cb: (e: Event) => void) => void
trigger: () => boolean
}
export type ReactiveItem = Reactive<any>
/**
*
*/
//export type Item<T> = Reactive<T>
//export type ItemList<T> = Record<string, Reactive<T>>
export type UseStoreMethod = <T>(key: string, def?: T) => Reactive<T>
export interface ItemWithUid<T> {
uid: string,
item: Reactive<T>
}
export type RemoveUid<T> = Omit<T, 'uid'>
/**
* Represents an item modeled after \<T\>.
* This helper removes uid and all functions from type.
*/
//TODO: properties that are pointing to models must be recognized as UIDs.
export type ListItem<T> = RemoveUid<NonFunctionProperties<T>>
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
export interface ReactiveList {
trigger: () => void,
subscribe: () => void,
push: (val: string) => void,
remove: (uid: string) => void,
entries: []
}