0.1.2 • Published 9 years ago

@koax/timing v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

timing

Build status Git tag NPM version Code style

Delay, timeout, and interval effects. (Included in koax)

Installation

$ npm install @koax/timing

Usage

import {delay, timeout, interval} from '@koax/timing'

function * () {
  yield delay(500)
  // do something later
}

function * () {
  yield timeout(doSomethingLater, 500)
  // do something now
}

function * () {
  let task = yield interval(repeatSomething, 500)
  // do something and then cancel
  yield cancel(task)
}

API

delay(wait)

  • wait - time to block

Returns: delay action

timeout(fn, wait)

  • fn - function to run after wait ms
  • wait - time to wait

Returns: timeout action

interval(fn, wait)

  • fn - function to run on an interval
  • wait - time in between runs

Returns: interval action

License

MIT