UNPKG

piral-base

Version:

The base library for creating a Piral instance.

40 lines (39 loc) 2.13 kB
import type { LoadPiletsOptions, PiletsLoaded, PiletLoadingStrategy } from './types'; /** * This strategy is dependent on the async parameter. If false it will start rendering when * everything has been received, otherwise it will start rendering when the metadata has been * received. In any case it will evaluate pilets as fast as possible. * @param async Uses the asynchronous mode. */ export declare function createProgressiveStrategy(async: boolean): PiletLoadingStrategy; /** * This strategy starts rendering when the pilets metadata has been received. * Evaluates the pilets once available without waiting for all pilets to be * available. */ export declare function blazingStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>; /** * The async strategy picked when no strategy is declared and async is set to * true. Directly renders, but waits for all pilets to be available before * evaluating them. */ export declare function asyncStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>; /** * The standard strategy that is used if no strategy is declared and async is * false. Loads and evaluates all pilets before rendering. */ export declare function standardStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>; /** * The strategy that could be used for special purposes, e.g., SSR or specific * builds of the Piral instance. This strategy ignores the fetcher and only * considers the already given pilets. */ export declare function syncStrategy(options: LoadPiletsOptions, cb: PiletsLoaded): PromiseLike<void>; /** * Creates a strategy that deferres the actual loading until a trigger promise resolves. * The loading spinner is not shown during this time and pilets are supposed to appear directly. * @param trigger The trigger resolving when the strategy should be applied. * @param strategy The strategy to apply. Falls back to the standard strategy. * @returns A pilet loading strategy. */ export declare function createDeferredStrategy(trigger: Promise<void>, strategy?: typeof standardStrategy): PiletLoadingStrategy;