UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

82 lines 3.12 kB
import { Injector, InjectionToken } from '@angular/core'; import { Router } from '@angular/router'; import { Observable } from 'rxjs'; import { Action } from './action.model'; import { ExtensionFactory, GenericHookType, ExtensionPointForPlugins, GenericHookOptions } from '../common/extension-hooks'; import { PluginsResolveService } from '../plugins/plugins-resolve.service'; import * as i0 from "@angular/core"; /** * An extension HOOK can use either a pure value: * ```typescript * { provide: HOOK_X, useValue: { ...hookValue }, multi: true } * ``` * * Or an array to directly register multiple: * ```typescript * { provide: HOOK_X, useValue: [{ ...hookValues }], multi: true } * ``` * * Or an ExtensionFactory which allows to define a get() function. This function * gets called on each navigation with the current route and can return values * async (observable or promise). * ```typescript * { provide: HOOK_X, useFactory: { get: (route) => doSomethingAsync(route) }, multi: true } * ``` */ export type ActionExtension = Action | Action[] | ExtensionFactory<Action>; /** * A hook to add an action using the multi-provider extension concept. * @deprecated Consider using the `hookAction` function instead. */ export declare const HOOK_ACTION: InjectionToken<unknown>; /** * A hook to add an action using the multi-provider extension concept. * * You can either provide a single `Action` as parameter: * ```typescript * hookAction(...) * ``` * * Or an array to directly register multiple: * ```typescript * hookAction([...]) * ``` * * Or you provide an Service that implements `ExtensionFactory<Action>` * ```typescript * export class MyActionFactory implements ExtensionFactory<Action> {...} * ... * hookAction(MyActionFactory) * ``` * A typed alternative to `HOOK_ACTION`. * @param actions The `Action`'s or `ExtensionFactory` to be provided. * @returns An `Provider` to be provided in your module. */ export declare function hookAction(actions: GenericHookType<Action>, options?: Partial<GenericHookOptions>): import("@angular/core").ValueProvider | import("@angular/core").ExistingProvider | import("@angular/core").ClassProvider; /** * A service which defines global actions. */ export declare class ActionService extends ExtensionPointForPlugins<Action> { private router; constructor(rootInjector: Injector, router: Router, plugins: PluginsResolveService); /** * Returns the current state. * @readonly * @returns The current set of actions. */ get state(): Set<Action>; /** * Adds a new item to the actions in the header and emits a state change. * @param item The item to add. */ add(item: Action): void; /** * Removes an action from the header and emits a state change. * @param item The item to remove. */ remove(item: Action): void; protected setupItemsObservable(): Observable<Action[]>; static ɵfac: i0.ɵɵFactoryDeclaration<ActionService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ActionService>; } //# sourceMappingURL=action.service.d.ts.map