Skip to content

Instantly share code, notes, and snippets.

View seidme's full-sized avatar

Seid M seidme

View GitHub Profile
@seidme
seidme / puppies-store.service.ts
Created April 5, 2020 01:55
An example of simple immutable RxJs store in Angular.
import { Injectable } from '@angular/core';
import { BehaviorSubject, Subject } from 'rxjs';
import { PuppiesModule } from './puppies.module';
import { Puppy } from './puppy.model';
@Injectable({ providedIn: PuppiesModule })
export class PuppiesStoreService {
// Make _puppiesSource private so it's not accessible from the outside,
// expose it as puppies$ observable (read-only) instead.