Skip to content

👜 Callbag source that after given duration emits numbers in sequence every specified duration.

Notifications You must be signed in to change notification settings

Andarist/callbag-timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

callbag-timer

Observable source that after given duration, emit numbers in sequence every specified duration.

Examples

With single argument

import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import timer from 'callbag-timer'

pipe(
  timer(1000),
  forEach(value => {
    // will log 0
    console.log(value)
  }),
)

With both parameters used

import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import timer from 'callbag-timer'

pipe(
  timer(1000, 2000),
  forEach(value => {
    // will log 0 1 2 3 4 ...
    console.log(value)
  }),
)

With Date

import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import timer from 'callbag-timer'

const date = new Date(Date.now() + 10000)

pipe(
  timer(date, 2000),
  forEach(value => {
    // will log 0 1 2 3 4 ...
    console.log(value)
  }),
)

Used as notifier source

import dropUntil from 'callbag-drop-until'
import forEach from 'callbag-for-each'
import pipe from 'callbag-pipe'
import interval from 'callbag-interval'
import timer from 'callbag-timer'

pipe(
  interval(1000),
  dropUntil(timer(6000)),
  forEach(value => {
    // will log 5 6 7 8 ...
    console.log(value)
  }),
)

About

👜 Callbag source that after given duration emits numbers in sequence every specified duration.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published