@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
90 lines • 3.63 kB
TypeScript
import { InjectionToken, Injector } from '@angular/core';
import { Router } from '@angular/router';
import { IManagedObject } from '@c8y/client';
import { Observable } from 'rxjs';
import { ExtensionFactory, ExtensionPointWithoutStateForPlugins, GenericHookOptions, GenericHookType } from '../common/extension-hooks';
import { OptionsService } from '../common/options.service';
import { PluginsResolveService } from '../plugins/plugins-resolve.service';
import { ContextRouteService } from './context-route.service';
import { Route, RouteFactory } from './router.model';
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 RouteExtension = Route | Route[] | ExtensionFactory<Route>;
/**
* A hook to use for Multi Provider extension.
* @deprecated Consider using the `hookRoute` function instead.
*/
export declare const HOOK_ROUTE: InjectionToken<RouteFactory>;
/**
* You can either provide a single `Route` as parameter:
* ```typescript
* hookRoute(...)
* ```
*
* Or an array to directly register multiple:
* ```typescript
* hookRoute([...])
* ```
*
* Or you provide an Service that implements `ExtensionFactory<Route>`
* ```typescript
* export class MyRouteFactory implements ExtensionFactory<Route> {...}
* ...
* hookRoute(MyRouteFactory)
* ```
* A typed alternative to `HOOK_ROUTE`.
* @param route The `Route`'s or `ExtensionFactory` to be provided.
* @returns An `Provider` to be provided in your module.
*/
export declare function hookRoute(route: GenericHookType<Route>, options?: Partial<GenericHookOptions>): import("@angular/core").ValueProvider | import("@angular/core").ExistingProvider | import("@angular/core").ClassProvider;
/**
* A service which defines routes for the application. You can use
* HOOK_ROUTES or pass
*/
export declare class RouterService extends ExtensionPointWithoutStateForPlugins<Route> {
router: Router;
private contextRouteService;
readonly state: Map<string, Route>;
constructor(rootInjector: Injector, router: Router, contextRouteService: ContextRouteService, plugins: PluginsResolveService, options: OptionsService);
/**
* Refresh the current context
*/
refresh(): void;
/**
* Add a new route to the router configuration or a context.
* @param route The route to add
*/
addRoute(route: Route | Route[]): void;
/**
* Determines if the given MO is an group or an device and returns
* the correct href to link correctly to that MO.
* @param groupOrDevice The MO of a group or the device.
* @param prefix How should the link be prefixed.
*/
getHref(groupOrDevice: IManagedObject, prefix?: string): string;
protected setupItemsObservable(): Observable<Route[]>;
private addRoutes;
private convertRoute;
private findAllRootContextRoutes;
private resolveRouterForChildRoutes;
static ɵfac: i0.ɵɵFactoryDeclaration<RouterService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<RouterService>;
}
//# sourceMappingURL=router.service.d.ts.map