[RxJS] Getting Input Text with Map
By default, Inputs will push input events into the stream. This lesson shows you how to use map
to convert the input event into the text you actually want.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.1/dist/global/Rx.umd.js"></script> <title>JS Bin</title> </head> <body> <input type="text" id="input"> </body> </html>
const input = document.querySelector('#input'); const input$ = Observable.fromEvent(input, 'input') .map(event => event.target.value); input$ .subscribe((x)=> console.log(x));