-
Notifications
You must be signed in to change notification settings - Fork 35
/
index.ts
66 lines (46 loc) · 1.22 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
export interface PlainObject {
[prop: string]: any
}
export interface EventBus {
on(name: string, execute: Function, ctx?: any): string
once(name: string, execute: Function, ctx?: any): string
remove(name: string, eventId?: string): EventBus
emit(name: string, ...args: any[]): EventBus
find(name: string): Event | null
clear(): EventBus
app<T extends Context>(ctx: T): InyApp<T>
page<T extends Context>(ctx: T): InyPage<T>
component<T extends Context>(ctx: T): InyComponent<T>
[propName: string]: any
}
export interface EventBusInstance extends EventBus {
create(): EventBus
}
export interface Event {
name: string
executes: Execute[]
}
export interface Execute {
id: string
execute: Function
ctx?: any
}
export interface InyEvent {
handler: (...args: any[]) => any
once: boolean
}
export interface BusEvents {
[prop: string]: ((...args: any[]) => any) | InyEvent
}
export interface InyEventIdNames {
id: string
name: string
}
export interface Context {
busEvents?: BusEvents
__inyEventIds?: InyEventIdNames[]
[prop: string]: any
}
export type InyApp<T> = Partial<T> & Context
export type InyPage<T> = Partial<T> & Context
export type InyComponent<T> = Partial<T> & Context