Skip to content

Instantly share code, notes, and snippets.

View tomasklingen's full-sized avatar

Tomas tomasklingen

View GitHub Profile
@tomasklingen
tomasklingen / rxjs-store.ts
Created January 3, 2019 09:51
rxjs store pattern
import { Observable, Subject, ReplaySubject } from "rxjs";
export abstract class Store<T> {
public value$: Observable<T>;
private subject: Subject<T> = new ReplaySubject<T>(1);
constructor(initialValue?: T) {
this.value$ = this.subject.asObservable();