import { Destroyable } from '../utils/Destroyable'; import { Realm } from '../realm/Realm'; export type SubscribeCallbackParam = { /** Update reason */ reason: string; /** Before value */ before: T; /** After value */ after: T; }; export type SubscribeCallback = (param: SubscribeCallbackParam) => void; export declare class Signal extends Destroyable { readonly realm: Realm; readonly key: string; readonly _subscribes: SubscribeCallback[]; value: T; constructor(realm: Realm, key: string, value: T); private _checkValid; private _fire; private _clearSubscribes; /** * Return a signal's value. * @returns Signal's value */ get(): T; /** * Update signal's value. * @param value New value * @param reason Update reason * @returns New Value */ set(value: T, reason: string): T; /** * Add Subscribe callback function to signal. * When `set` method called, all callbacks will be called by order. * @param callback Callback function */ subscribe(callback: SubscribeCallback): void; /** * Remove subscribe callback function from signal. * @param callback Added Callback function */ unsubscribe(callback: SubscribeCallback): void; /** * Destroy this instance. * You can pass a destruction reason, and this reason will be shown as an error message when signal's method calls after it is destroyed. * * **WARNING!** This method doesn't remove the signal instance from the realm. You should use this method when you are sure the signal instance will never be used again. * @param reason Destruction reason */ destroy(reason: string): void; }