0.2.1 • Published 10 months ago
@reactive-cache/map v0.2.1
Reactive Cache
Installation
$ npm install @reactive-cache/coreUsage
import { reactiveCache } from 'reactive-cache';
const data = reactiveCache(fetch('https://...'));
data.subscribe(console.log);Angular like
import { reactiveCache } from '@reactive-cache/core';
import { ajax } from 'rxjs/ajax';
import { Observable } from "rxjs";
export class FetchDataService {
public readonly response$ = reactiveCache.valueReadable<unknown>('response$', () => this.fetchData());
private fetchData(): Observable<unknown> {
return ajax.get('https://jsonplaceholder.typicode.com/posts');
}
}
const service = new FetchDataService();
service.data.subscribe(console.log)
console.log(service.data.getValue());