const input = document.querySelector('input[type=text]'); const p = document.querySelector('p'); input.addEventListener('input', event => { subject.next(event.target.value); }); subject.subscribe(val => { p.textContent = val; });