Skip to content
David Chase edited this page Apr 25, 2017 · 3 revisions

Use @most/dom-event to create a stream from a click event.

By adding filter in conjunction with Element.matches we can specify which element we want to observe and in this case get the textContent from the element.

import { click } from '@most/dom-event'

const container = document.querySelector('.container')

click(container)
    .filter(e => e.target.matches('.hello'))
    .observe(e => console.log(e.target.textContent))