import { Job, Scheduler as SchedulerInterface } from '@zedux/core'; import { Ecosystem } from './Ecosystem'; export declare class Scheduler implements SchedulerInterface { private readonly ecosystem; /** * We set this to true internally when the scheduler starts flushing. We also * set it to true when batching updates, to prevent anything from flushing. */ _isRunning?: boolean; _isRunningNows?: boolean; /** * The dynamic list of "full" jobs to run. Full jobs are: * * - EvaluateGraphNode (2) * - UpdateExternalDependent (3) * - RunEffect (4) */ private jobs; /** * The dynamic list of "now" jobs to run. Now jobs are: * * - UpdateStore (0) * - InformSubscribers(1) */ private nows; private _handle?; private _runAfterNows?; constructor(ecosystem: Ecosystem); /** * Kill any current timeout and run all jobs immediately. * * IMPORTANT: Setting and clearing timeouts is expensive. We need to always * pass `shouldSetTimeout: false` to scheduler.schedule() when we're going * to immediately flush */ flush(): void; /** * Insert a job into the queue. Insertion point depends on job's type and * weight. * * IMPORTANT: Setting and clearing timeouts is expensive. We need to always * pass `shouldSetTimeout: false` when we're going to immediately flush */ schedule(newJob: Job, shouldSetTimeout?: boolean): void; /** * UpdateStore (0) jobs must run immediately but also need the scheduler to be * running all "now" jobs. * * InformSubscriber (1) jobs must run immediately after the current task. */ scheduleNow(newJob: Job): void; unschedule(task: () => void): void; wipe(): void; private findIndex; /** * Schedule an EvaluateGraphNode (2) or UpdateExternalDependent (3) job */ private insertJob; /** * Run either all "full" jobs or all "now" jobs. Since the jobs are split, we * can essentially have two schedulers running at once. "Now" jobs must always * run before any "full" jobs, so the "full" jobs runner has to flush any * "now"s that come up while it's flushing "full"s. * * Don't run "full" jobs while "now"s are running. It leads to "now"s being * deferred until after "full"s finish. This is backwards and can lead to * reevaluation loops. */ private runJobs; private setTimeout; }