Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Subject } from 'rxjs';
- import { debounceTime, distinctUntilChanged, startWith, switchMap } from 'rxjs/operators';
- import { CarsRemoteService } from './cars-remote.service';
- @Injectable()
- export class CarsV2Service {
- constructor(private carsRemoteService: CarsRemoteService) { }
- getCarsStream(querySubject: Subject<string>) {
- const carsQuery$ = querySubject.pipe(
- debounceTime(250),
- distinctUntilChanged(),
- startWith('')
- );
- return carsQuery$.pipe(
- switchMap(query => this.carsRemoteService.loadCars(query))
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement