ngx-smart-loader
Version:
Smart loader handler to manage loaders everywhere in Angular apps.
102 lines (101 loc) • 3.53 kB
TypeScript
import { LoaderInstance } from './loader-instance';
export declare class NgxSmartLoaderService {
private _loaderStack;
private _actions;
/**
* Add a new loader instance. This step is essential and allows to retrieve any loader at any time.
* It stores an object that contains the given loader identifier and the loader itself directly in the `loaderStack`.
*
* @param loaderInstance The object that contains the given loader identifier and the loader itself.
* @param force Optional parameter that forces the overriding of loader instance if it already exists.
* @returns Returns nothing special.
*/
addLoader(loaderInstance: LoaderInstance, force?: boolean): void;
/**
* Remove a loader instance from the loader stack.
*
* @param id The loader identifier.
*/
removeLoader(id: string): void;
/**
* Retrieve all the created loaders.
*
* @returns Returns an array that contains all loader instances.
*/
getLoaderStack(): LoaderInstance[];
/**
* It gives the number of loader instances. It's helpful to know if the loader stack is empty or not.
*
* @returns Returns the number of loader instances.
*/
getLoaderStackCount(): number;
/**
* Retrieve all the opened loaders. It looks for all loader instances with their `visible` property set to `true`.
*
* @returns Returns an array that contains all the opened loaders.
*/
getOpenedLoaders(): LoaderInstance[];
/**
* Retrieve all the active loaders. It looks for all loader instances with their `loading` property set to `true`.
*
* @returns Returns an array that contains all the active loaders.
*/
getActiveLoaders(): LoaderInstance[];
/**
* Get the higher `z-index` value between all the loader instances. It iterates over the `LoaderStack` array and
* calculates a higher value (it takes the highest index value between all the loader instances and adds 1).
* Use it to make a loader appear foreground.
*
* @returns Returns a higher index from all the existing loader instances.
*/
getHigherIndex(): number;
/**
* Enable loading state to one or several loaders.
*
* @param id The loader identifier.
*/
start(id: string | string[]): void;
/**
* Enable loading state to all loaders.
*/
startAll(): void;
/**
* Disable loading state to one or several loaders.
*
* @param id The loader identifier.
*/
stop(id: string | string[]): void;
/**
* Disable loading state to all loaders.
*/
stopAll(): void;
isLoading(id: string | string[]): boolean;
/**
* Execute an action on loaders
*
* @param id The loader identifier.
* @param action Name of the action.
*/
executeAction(id: string, action: string): void;
/**
* Retrieve a loader instance by its identifier.
* If there's several loaders with same identifier, the first is returned.
*
* @param id The loader identifier used at creation time.
*/
private _getLoader(id);
/**
* Adds an action on one or more loaders
*
* @param id The loader identifier.
* @param action Name of the action.
*/
private _addAction(id, action);
/**
* Remove an action on one or more loaders
*
* @param id The loader identifier.
* @param action Name of the action.
*/
private _removeAction(id, action);
}