import { InjectionToken } from '@angular/core';
import { type WrFeature, wrFeature } from 'ngwr/utils';
export interface MapsOptions {
readonly tiles?: string;
}
export const MAPS_OPTIONS = new InjectionToken<MapsOptions>('MAPS_OPTIONS', {
providedIn: 'root',
factory: () => ({}),
});
export function withMaps(options: MapsOptions = {}): WrFeature<'maps'> {
return wrFeature('maps', [{ provide: MAPS_OPTIONS, useValue: options }]);
}import { provideWr } from 'ngwr';
import { withDensity } from 'ngwr/density';
providers: [provideWr(withDensity({ defaultDensity: 'sm' }), withMaps({ tiles: '/tiles' }))],| Argument | What it is |
|---|---|
kind | The feature's name. In dev mode provideWr() throws when it gets the same kind twice, so pick one no other feature uses. |
providers | What the feature registers. provideWr() flattens them into its own providers. |
- Give the token a root default, so the setting is optional.
- Annotate the return type as
WrFeature<'kind'>. Do not read the object's members: they are private.