ngx-store
Version:
Angular decorators to automagically keep variables in HTML5 LocalStorage, SessionStorage, cookies; injectable services for managing and listening to data changes and a bit more.
36 lines (35 loc) • 1.61 kB
TypeScript
import { ClearType, WebStorageConfigInterface } from '../config/config.interface';
import { WebStorageUtility } from '../utility/webstorage.utility';
import { Observable } from 'rxjs';
import { NgxStorageEvent } from '../utility/storage/storage-event';
import { Resource } from './resource';
export declare abstract class WebStorageService {
utility: WebStorageUtility;
static keys: Array<string>;
protected _changes: Observable<NgxStorageEvent>;
protected constructor(utility: WebStorageUtility);
/**
* Gets keys for stored variables created by ngx-store,
* ignores keys that have not been created by decorators and have no prefix at once
*/
get keys(): Array<string>;
get config(): WebStorageConfigInterface;
get(key: string): any;
/**
* Returns new data Resource for given key exposing builder design pattern
* designed for complex nested data structures
*/
load(key: string): Resource<any>;
set<T>(key: string, value: T): T;
update(key: string, changes: any): any;
remove(key: string): void;
observe(key?: string, exactMatch?: boolean): Observable<NgxStorageEvent>;
/**
* Clears chosen data from Storage
* @param clearType 'prefix' | 'decorators' | 'all'
* @param prefixOrClass defines the prefix or class (not its instance) whose decorators should be cleared
*/
clear(clearType?: ClearType, prefixOrClass?: string | object): void;
protected generateEvent(key: string, newValue: any, oldValue?: any): NgxStorageEvent;
protected mapNativeEvent(ev: StorageEvent): NgxStorageEvent;
}