angular-persistence
Version:
A library to handle persistence for Angular 2 applications.
52 lines (51 loc) • 1.68 kB
TypeScript
import { Observable } from 'rxjs';
import { ICache } from '../abstracts/persistence.cache';
import { PersistenceService } from '../services/persistence.service';
import { CacheConfig } from '../types/persistence.cache_config';
/**
* Internal class which is an implementation of the ICache interface. This is
* intended to be a private class for framework use only and will not be
* exported by the libraries modules.
*
* @export
* @class CacheImpl
* @implements {ICache<T>}
* @template T the type of value being cached
*
* @author Scott O'Bryan
* @since 1.0
*/
export declare class CacheImpl<T> implements ICache<T> {
private _loader;
private _value;
private _cachedObservable;
private _changes;
/**
* Creates an instance of CacheImpl.
* @param {string} key
* @param {(() => T | Observable<T>)} _loader
* @param {PersistenceService} service
* @param {CacheConfig} [config]
*/
constructor(key: string, _loader: () => T | Observable<T>, service: PersistenceService, config?: CacheConfig);
/**
* Returns an observable to a cached value if one is loaded or
* to the value specified by the loader that was supplied when
* this cache was created if it is not.
*
* @returns {Observable<T>} an Observable of type T that will return a
* single value when it's available before marking the stream
* as complete.
*/
get(): Observable<T>;
/**
* A hot observable returning changes over time.
*
* @returns {Observable<T>}
*/
changes(): Observable<T>;
/**
* Clears the cached value forcing a reload.
*/
clear(): void;
}