UNPKG

@launchmenu/core

Version:

An environment for visual keyboard controlled applets

99 lines 4.2 kB
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<Q, I> { protected rootSearchable: ISearchable<Q, I>; protected onUpdate: (ID: IUUID, result: ICoreSearchResult<I>, oldResult: ICoreSearchResult<I>) => void; protected onRemove: (ID: IUUID, oldResult: ICoreSearchResult<I>) => void; protected executer?: SearchExecuter<Q, I>; protected query: Field<Q | null>; protected nodes: Record<IUUID, ICoreSearchNode<Q, I>>; /** The update queues, in order of priority, empties searchUpdate before removal, etc */ protected queues: { searchUpdate: Queue<IUUID>; removal: Queue<IUUID>; update: Queue<IUUID>; addition: Queue<IUUID>; }; protected searching: Field<boolean>; protected searchPromise: Promise<void>; protected continue: null | ((finished?: boolean) => void); protected destroyed: Field<boolean>; /** * Creates a new search executor * @param config The search configuration */ constructor({ searchable, onUpdate, onRemove, executer, }: ICoreSearchExecuterConfig<Q, I>); /** * 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<void>; /** * 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<void>; /** * 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<Q, I>, 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<void>; /** * 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