Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

@most/hold

3.0.0 • Public • Published

@most hold()

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

Install

npm install --save @most/hold

Usage

import { fromEvent } from 'most'
import { hold } from '@most/hold'
 
// start holding on first subscription
const clickStream = fromEvent('click', document)
  .map(e => ({ x: e.clientX, y: clientY }))
  .thru(hold)
 
// hold the latest event even before the first subscription
clickStream.drain();

API

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->

install

npm i @most/hold

Downloadsweekly downloads

154

version

3.0.0

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar