import { ObservableCache } from '../ObservableCache'; import { IObservableCache } from '../IObservableCache'; import { isObservable, Observable } from 'rxjs'; import { IChangeSet } from '../IChangeSet'; /** * Converts the source to an read only observable cache * @typeparam TObject The type of the object * @typeparam TKey The type of the key * @param source The source */ export function asObservableCache(source: IObservableCache): IObservableCache; /** * Converts the source to an read only observable cache * @typeparam TObject The type of the object * @typeparam TKey The type of the key * @param source The source * @param deepEqual Use deep equality with the cache */ export function asObservableCache(source: Observable>, deepEqual?: boolean): IObservableCache; export function asObservableCache( source: IObservableCache | Observable>, deepEqual = false, ): IObservableCache { if (isObservable(source)) { return new ObservableCache(source, deepEqual); } else { return source; } }