@genialis/resolwe
Version:
Resolwe frontend libraries
78 lines (77 loc) • 2.67 kB
TypeScript
import { StatefulComponentBase } from './stateful';
import { SharedStoreManager } from '../shared_store/index';
/**
* Manager of all stateful components' state.
*/
export declare class StateManager {
private _sharedStoreManager;
private _topLevelComponents;
private _nextState;
constructor(sharedStoreManager: SharedStoreManager);
/**
* Returns the shared store manager.
*/
readonly sharedStoreManager: SharedStoreManager;
/**
* Adds a top-level component.
*
* @param component Top-level component instance
*/
addTopLevelComponent(component: StatefulComponentBase): void;
/**
* Removes a top-level component.
*
* @param component Top-level component instance
*/
removeTopLevelComponent(component: StatefulComponentBase): void;
/**
* Returns the current top-level component.
*/
topLevelComponents(): StatefulComponentBase[];
/**
* Saves a component's current state so it will be reloaded when the component
* is next constructed.
*
* @param component Target component
*/
savePendingComponentState(component: StatefulComponentBase): void;
/**
* Loads any pending state for a specified component. State may be pending if
* it gets loaded before the target component has been constructed. In this
* case it will get loaded as soon as the target component gets constructed.
*
* @param component Target component
*/
loadPendingComponentState(component: StatefulComponentBase): void;
/**
* Returns application state by combining component.saveState of all
* components and shared stores.
*
* When to use:
* - saving state into memory (non-serialized), e.g. like components do
* when they are destroyed
* - when you just need to collect components' saveState
* - if you need to store functions in state
* When not to use:
* - when saving state into a serialized form; use [[saveSerializableState]].
*/
save(): any;
/**
* Loads existing application state.
*
* @param state Application state
*/
load(state: any): void;
/**
* Saves this component's current state and returns it in a format that is
* safe to serialize. Values `undefined`, `NaN`, and `Infinity` are kept
* when stringified with JSON.stringify.
*
* When to use:
* - saving state into serialized forms, e.g. before transferring to backend
* When not to use:
* - to store functions
*/
saveSerializableState(): any;
loadSerializableState(serializableState: any): void;
}