Simple Input Observable

Creating Observable from the input event on a <input> field

by Mario_Rivis

HTML

<script src="https://unpkg.com/@reactivex/[email protected]/dist/global/Rx.js"></script>

<input id="my-input" class="my-class">

CSS

.my-class {
  background: red;
}

JavaScript

const myInput = document.getElementById('my-input');
  
Rx.Observable.fromEvent(myInput, 'input')
    .debounceTime(300)
    .map(event => event.target.value)
    .subscribe(console.log);