Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { Subject } from 'rxjs';
  3.  
  4. import { CarsRemoteService } from './cars-remote.service';
  5. import { search } from './search.operator';
  6.  
  7. @Injectable()
  8. export class CarsV3Service {
  9. private carsQuerySubject = new Subject<string>();
  10.  
  11. readonly cars$ = this.carsQuerySubject.pipe(
  12. search(query => this.carsRemoteService.loadCars(query))
  13. );
  14.  
  15. constructor(private carsRemoteService: CarsRemoteService) { }
  16.  
  17. searchCars(query: string) {
  18. this.carsQuerySubject.next(query);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement