Angular http.get returns an RxJS Observable
The AngularObservable is a bare-bones implementation.In the promise’s then callback we call the json method of the HTTP Response to extract the data within the response.for example:.then(response => response.json().data as Hero[])
Each Http service method returns an Observable of HTTP Response objects.
The async pipe subscribes to the ObservableA Subject is a producer of an observable event stream
A Subject is also an ObservabledebounceTime(300) waits until the flow of new string events pauses for 300 milliseconds before passing along the latest string. We’ll never make requests more frequently than 300ms.
distinctUntilChanged ensures that we only send a request if the filter text changed. There’s no point in repeating a request for the same search term.switchMap calls our search service for each search term that makes it through the debounce anddistinctUntilChanged gauntlet. It cancels and discards previous search observables, returning only the latest search service observable.
Angular2(九)--http
最新推荐文章于 2021-01-08 16:06:50 发布