import type { SubscribeCallback } from '../signal/Signal'; interface RealmConnectorList extends Record { } interface DefaultRealmConnectorList extends RealmConnectorList { [key: string]: any; } /** * Unsubscribe value updating. * If you call this function, the subscript that returned this function will be canceled. * @example * const unsubscribe = subsVar(({ before, after, reason }) => { ... }) * unsubscribe() */ export declare function Unsubscribe(): void; export declare class IRealmConnector { /** * Get or create a variable for this realm. If this variable has never been used before, it will create a new variable with this value. Otherwise, get an existing variable. * @param key Variable name * @param initialValue The initial value. If this variable has never been used before, it will create a new variable with this value. */ use(key: K, initialValue: R[K]): [ /** * Get a value */ () => R[K], /** * Set a value * @param value New value * @param reason Updating reason. If you are using a `subscribe` function, you can receive a reason when the value is updated. */ (value: R[K], reason?: string) => R[K], /** * You can register subscribe callbacks to watch this variable change. * If the variable is changed, all subscribe callbacks will be called. * This function returns a new function that can be cancel unsubscribed. If you want, just call the returned function. * @example * const unsubscribe = subsVar(({ before, after, reason }) => { ... }) * unsubscribe() * @param callback callback function */ (callback: SubscribeCallback) => typeof Unsubscribe, /** * Destroy a variable. * * **WARNING!** You can't use a same name of variable after destroyed. You should use this function when you are sure the variable will never be used again. * @param reason Destruction reason */ (reason?: string) => void ]; /** * Returns `true` if a variable exists in the realm, or `false` if not. * @param key Variable name */ exists(key: keyof R): boolean; } /** * Get or create a realm for this scope. * If this realm has never been used before, it will create a new realm with this value. Otherwise, get an existing realm. * @param scope The scope of the realm. You can use both primitive types and plain objects. */ export declare function openRealm(scope: any): IRealmConnector; /** * Destroy the realm. All variables belonging to this realm are also destroyed. * @param scope The scope of the realm. You can use both primitive types and plain objects. * @param reason Destruction reason */ export declare function destroyRealm(scope: any, reason: string): boolean; export {};