UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

45 lines (44 loc) 1.54 kB
import State from '../state/state'; import StateManager from '../state/statemanager'; /** * Manages the toggling of state properties based on specified paths. * Every paths leading to boolean value will be initially set to false, * then activities one will deactivate the others. */ export default class StateToggleManager { private stateManager; private readonly eventsCallbacks; private togglePaths; constructor(togglePaths: string[], stateManager: StateManager); get state(): State; /** * To call to destroy properly the component. */ destroy(): void; /** * Set to false every state leaded by toggle paths except the specified one. * Use the given value on the specified one. */ toggle(setPath: string, newValue: boolean): void; /** * Set to false every state leaded by toggle paths. */ deactivateAll(): void; /** * Initializes the toggle for the given paths. * If any of the paths has a truthy value in the state, sets all other paths to false. * @private */ private initToggle; /** * Watches for changes in togglePaths and invokes the toggle method when a change is detected. * @private **/ private watchToggle; /** * Filters out invalid toggle paths from the given array of paths. * Invalid path are path not leading to object in the state, or not leading to boolean value. * @static */ static filterValidTogglePaths(stateManager: StateManager, paths: string[]): string[]; }