Skip to content
Brandon Payton edited this page Jun 25, 2016 · 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))
Clone this wiki locally