Emit latest event to new observers


31194.1.02 years ago6 years agoMinified + gzip package size for @most/hold in KB


@most hold()

Deliver the most recently seen event to each new observer the instant it begins observing. A held stream is always multicast.

Note: @most/hold >= 3.0.0 is compatible with @most/core. Use @most/hold 2.x for compatibility with most 1.x.


npm install --save @most/hold


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

const clickCoords = map(e => ({ x: e.clientX, y: clientY }), click(document))

// start holding on first subscription
const heldCoords = hold(clickCoords)


hold :: Stream a → Stream a

Given an input stream:

stream:    -a---b---c---d->

observers which begin observing at different times will see:

observer1: -a---b---c---d->
observer2:    a-b---c---d->
observer3:           c--d->

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.