ViewBase.ts
994 Bytes
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
import { Event, Emitter } from "simba-eventkit";
export interface View {
readonly _type: "View";
name: string;
open(parent: View): void;
show(): void;
hide(): void;
close(destroy?: boolean): void;
readonly isHidden: boolean;
onShow: Event<() => void>;
onHide: Event<() => void>;
onClose: Event<() => void>;
}
export interface Subview {
readonly _type: "Subview";
name: string;
attachParent(parent: View): void;
show(): void;
hide(): void;
readonly isHidden: boolean;
onShow: Event<() => void>;
onHide: Event<() => void>;
}
interface PureViewBase<P> {
setProps(props: P): void;
updateProps(props: Partial<P>): void;
// onLoadProps(props: P): void;
// onPropChange(key: keyof P): void;
}
let emitter = new Emitter;
export const OnSubviewCreated = emitter.createEvent<(subview: Subview) => void>();
export type PureView<P> = PureViewBase<P> & View;
export type PureSubview<P> = PureViewBase<P> & Subview;