@nova-ui/bits
Version:
SolarWinds Nova Framework
48 lines (47 loc) • 1.32 kB
TypeScript
import * as i0 from "@angular/core";
/**
* This class can help with storing and managing the history of state mutations
*/
export declare class HistoryStorage<T> {
private stack;
/**
* The index of current history element (equals -1 when there are no items, 0 for first item)
*/
index: number;
/**
* Add a new record to the storage
*
* @param value
*/
save(value: T): T;
/**
* Rewind the history and return the record before the last one. A redo will still be available after this.
*/
undo(): T;
/**
* Moves on to the next step in history if undo was previously triggered
*/
redo(): T;
/**
* Clears the storage
*/
reset(): void;
/**
* Clears the storage and saves the initial value or preserves the previous one
*/
restart(value?: T): T;
/**
* Returns the currently valid stored element
*/
current(): T;
/**
* Returns the current history step (starts from 0 when there are no items, 1 for one item)
*/
get step(): number;
/**
* Number of total saved steps in the history
*/
get length(): number;
static ɵfac: i0.ɵɵFactoryDeclaration<HistoryStorage<any>, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<HistoryStorage<any>>;
}