Star

Created With


take



Take a maximum number of values from source:

1linkfunction take<I>(n: number): (src: Source<I>) => Source<I>

1linkimport { interval, take, subscribe, pipe } from 'callbag-common';

2link

3linkpipe(

4link interval(1000),

5link take(3),

6link subscribe(console.log),

7link)

0 1 2
► Try It!



👉 take() will unsubscribe from its source after it has read its values, so using take(1) is a safe way of reading the next value of the source:

1linkimport { pipe, take, subscribe } from 'callbag-common';

2link

3linkexport function logNext(cb) {

4link pipe(

5link cb,

6link take(1),

7link subscribe(console.log) // --> you don't need to unsubscribe

8link )

9link}




Home What Are Callbags?

Source Factorieschevron_right
Operatorschevron_right
Combinationchevron_right
Utilitieschevron_right