import { HttpClient } from '@angular/common/http'; import { Inject, Injectable } from '@angular/core'; import { HistoryStore } from './history.store'; import { CFG } from '../../const'; import { BaseApi } from '../../core/base-api.class'; import { tap } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class HistoryService extends BaseApi { constructor( @Inject(CFG) protected cfg: any, private historyStore: HistoryStore, private http: HttpClient ) { super(); } fetchAll() { return this.http.get(`${this.endpoint}/client/devices/completed`).pipe( tap(data => this.historyStore.set(data)) ); } }