Monday, August 10FreeJQuery

Tag: FlatMap

FlatMap In Angular
2019, Ajax, AngularJS

FlatMap In Angular

FlatMap In Angular This Article is about FlatMap In Angular. Let's say we wanted to implement an AJAX search feature in which every keypress in a text field will automatically perform a search and update the page with the results. How would this look? Well we would have an Observable subscribed to events coming from an input field, and on every change of input we want to perform some HTTP request, which is also an Observable we subscribe to. What we end up with is an Observable of an Observable. By using flatMap we can transform our event stream (the keypress events on the text field) into our response stream (the search results from the HTTP request). app/services/search.service.tsCODE:import {Http} from '@angular/http'; import {Injectable} from '@angular/core'; ​...