2.0.0 • Published 4 years ago

callbag-remember v2.0.0

Weekly downloads
496
License
MIT
Repository
github
Last release
4 years ago

callbag-remember

Callbag operator which shares input stream between subscribers and emits last emitted value upon subscription. It behaves pretty much as Rx's .shareReplay(1).

Example

import fromEvent from 'callbag-from-event'
import forEach from 'callbag-for-each'
import map from 'callbag-map'
import merge from 'callbag-merge'
import pipe from 'callbag-pipe'
import remember from 'callbag-remember'

const focus$ = remember(
  merge(
    map(() => false)(fromEvent(window, 'blur')),
    map(() => true)(fromEvent(window, 'focus')),
  ),
)

pipe(
  focus$,
  forEach(tabFocused => {
    // ...
  }),
)

// ...

setTimeout(() => {
  pipe(
    focus$,
    forEach(tabFocused => {
      // ... will get last emitted value immediately
    }),
  )
}, 1000)
2.0.0

4 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.0

7 years ago