import type { QuarkElement } from "./main"; /** current watcher that is collecting it's dependencies */ export declare let currDepTarget: Watcher | undefined; export type WatcherGetter = () => any; export declare const nextTick: (cb?: (...args: any[]) => any, ctx?: any) => false | Promise; interface SharedWatcherOptions { /** watcher's callback */ cb?: (newVal: any, oldVal: any) => void; } export interface UserWatcherOptions extends SharedWatcherOptions { /** call immediately after first-time render */ immediate?: boolean; } interface InternalWatcherOptions extends SharedWatcherOptions { /** is render watcher */ render?: boolean; /** is computed watcher */ computed?: boolean; } type WatcherOptions = UserWatcherOptions & InternalWatcherOptions; export declare class Watcher { /** watcher's id */ id: number; /** * watcher itself can be dependency of others' * * so you can treat it as watcher itself (for maintaining dependencies) */ dep: Dep; /** this watcher's dependencies */ deps: Map; oldDeps: Map; /** watcher's getter function */ getter: WatcherGetter; /** quark element's instance */ inst: QuarkElement; /** computed value */ value: any; /** is computed value dirty */ dirty: boolean; /** is computed watcher */ computed: boolean; /** watcher's callback */ cb: ((newVal: any, oldVal: any) => void); /** is render watcher */ render: boolean; constructor(inst: QuarkElement, getterOrExpr: WatcherGetter | string, options: WatcherOptions); /** get latest computed value of watcher */ get(): any; /** invoke getter, recompute value, manage dependencies */ compute(): any; /** clean invalidated dependencies */ cleanDeps(): void; /** add dependency to this watcher's dependency list */ addDep(dep: Dep): void; /** mark itself as a dependency of current watcher */ depend(): void; /** invoke callback after successfully updated */ updateAndInvoke(cb: (newValue: any, oldValue: any) => void): void; /** receive update notification from it's dependency */ update(): void; /** run callback of watcher */ run(): void; } export declare class Dep { /** dependecy id */ id: number; /** watchers that are watching this dependecy, listening to its changes */ watchers: Set; constructor(); /** a watcher subscribe to this dependency */ watch(watcher: Watcher): void; /** stop watching this dependency */ unwatch(watcher: Watcher): void; /** notify update to its watchers */ notify(): void; /** * mark itself as a dependency of current watcher. * in other words, current watcher depends on it. */ depend(): void; } /** setter for {@link currDepTarget} */ export declare const setCurrDepTarget: (target: Watcher) => void; export declare const popCurrDepTarget: () => void; export {};