1 export interface BaseEvent {
6 export type EventPayloadMap<E extends BaseEvent> = {
7 [K in E['name']]: Extract<E, { name: K }>['payload']
10 export interface BasePropertyValues {}
12 export type PropertyCallback<T extends keyof P, P extends BasePropertyValues> = (
14 previousValue: P[T] | undefined,
17 export interface BasePropertiesStateInterface<P extends BasePropertyValues, E extends BaseEvent> {
18 subscribe: (callback: (state: P) => void) => () => void
19 subscribeToProperty<T extends keyof P>(property: T, callback: PropertyCallback<T, P>): () => void
20 setProperty: <T extends keyof P>(property: T, value: P[T]) => void
21 getProperty: <T extends keyof P>(property: T) => P[T]
24 emitEvent(event: E): void
25 subscribeToEvent<T extends E['name']>(event: T, callback: (payload: EventPayloadMap<E>[T]) => void): () => void