@reactive-cache/core
v1.2.0
Published
reactive cache for angular and rxjs or signal projects
Downloads
270
Maintainers
Readme
Reactive Cache
Installation
$ npm install @reactive-cache/core
Usage
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 data = reactiveCache<unknown>(this.fetchData.bind(this), { name: 'response', valueReachable: true });
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());