UNPKG

@difizen/mana-observable

Version:

33 lines 1.28 kB
import type { Disposable } from '@difizen/mana-common'; import { Event } from '@difizen/mana-common'; import { AsyncEmitter } from './async-event'; import type { Notify } from './core'; export interface Notification<T = any> { target: T; prop?: any; } export declare class Notifier implements Disposable { protected changedEmitter: AsyncEmitter<Notification<any>>; disposed: boolean; get onChange(): Event<any>; get onChangeAsync(): Event<Notification<any>>; get onChangeSync(): Event<any>; dispose(): void; once(trigger: Notify, context?: any): Disposable; notify(target: any, prop?: any): void; static trigger(target: any, prop?: any): void; static getOrCreate(target: any, prop?: any): Notifier; static find(target: any, prop?: any): Notifier | undefined; static get(target: any, property?: any): Notifier | undefined; static set(target: any, notifier: Notifier, property?: any): void; static once(notifier: Notifier, key: any, onChange: () => void): void; /** * Get event from target * @param target * @param prop * @param async false by default * @returns */ static toEvent(target: any, prop?: any, async?: boolean | null): Event<any>; } //# sourceMappingURL=notifier.d.ts.map