import { Field, IDataHook } from "model-react"; import { IUUID } from "../../_types/IUUID"; import { Queue } from "../Queue"; import { ISearchable } from "./_types/ISearchable"; import { ICoreSearchNode } from "./_types/ICoreSearchNode"; import { ICoreSearchExecuterConfig, ICoreSearchResult } from "./_types/ICoreSearchExecuterConfig"; import { SearchExecuter } from "./SearchExecuter"; /** * The core of the search executer that will obtain all the results */ export declare class CoreSearchExecuter { protected rootSearchable: ISearchable; protected onUpdate: (ID: IUUID, result: ICoreSearchResult, oldResult: ICoreSearchResult) => void; protected onRemove: (ID: IUUID, oldResult: ICoreSearchResult) => void; protected executer?: SearchExecuter; protected query: Field; protected nodes: Record>; /** The update queues, in order of priority, empties searchUpdate before removal, etc */ protected queues: { searchUpdate: Queue; removal: Queue; update: Queue; addition: Queue; }; protected searching: Field; protected searchPromise: Promise; protected continue: null | ((finished?: boolean) => void); protected destroyed: Field; /** * Creates a new search executor * @param config The search configuration */ constructor({ searchable, onUpdate, onRemove, executer, }: ICoreSearchExecuterConfig); /** * Sets the query to look for * @param query The new query * @returns A promise that resolves when the search fully finished */ setQuery(query: Q | null): Promise; /** * Retrieves the current query * @param hook The hook to subscribe to changes * @returns The current query */ getQuery(hook?: IDataHook): Q | null; /** * Retrieves whether a search is currently in progress * @param hook The hook to subscribe to changes * @returns Whether any search is in progress */ isSearching(hook?: IDataHook): boolean; /** * Destroys the search executer * @param keepResults Whether to preserve the items (instead of calling onRemove for all) */ destroy(keepResults?: boolean): void; /** * Starts or continues the search, if it wasn't already going */ protected initSearch(): void; /** * Starts the search process * @returns A promise that resolves once the search finishes */ protected search(): Promise; /** * Schedules the addition of a new searchable * May also be used to 'add' nodes that are already in the system, under a new parent * @param searchable The searchable node to be scheduled * @param parent The parent of the searchable node to add * @param dontStartSearch Whether to prevent a search from starting based on this addition */ protected scheduleAddition(searchable: ISearchable, parent: IUUID, dontStartSearch?: boolean): void; /** * Schedules an update for the node with the given ID * @param ID The ID of the node to schedule an update for */ protected scheduleUpdate(ID: IUUID): void; /** * Schedules the removal of the node with the given ID. * Only schedules the removal if this node has no more parents * @param ID The ID of the node to schedule the removal for * @param parent The parent from which this node was removed */ protected scheduleRemoval(ID: IUUID, parent: IUUID): void; /** * Updates the given node, using the new query * @param query The query to use for the update * @param ID The ID of the node to be updated * @returns A promise that resolves once the node is updated */ protected updateNode(query: Q, ID: IUUID): Promise; /** * Removes a node with the given ID from the system * @param ID The ID of the node to be removed */ protected removeNode(ID: IUUID): void; } //# sourceMappingURL=CoreSearchExecuter.d.ts.map