パッケージの詳細

wait-ready

rocwind163MIT0.6.0

a utility for executing actions after some async tasks complete

readme

wait-ready npm npm downloads Node.js CI

a promise based utility for perform actions after async tasks finished

Install

npm i --save wait-ready

Usage Example

// ES6 import
import { wait, withReady } from 'wait-ready'
// CommonJS require
const { wait, withReady } = require('wait-ready');

const { afterReady, setReady } = wait();
// wait for the ready status to perform some actions
afterReady().then(() => {
    // pending actions ...
})

// update ready status when and trigger the pending actions
setReady();

// set a name for wait task
const { afterLoadingReady, setLoadingReady } = wait('Loading');

// wrap a function to execute after ready
const doThingsAfterLoadingReady = withReady((param1) => {
    // do things with param1
    console.log('being execute afterLoadingReady', param1)
}, afterLoadingReady());

// just call the function, the execution will be delayed to afterLoadingReady
doThingsAfterLoadingReady('hello world');

Changelog

check out CHANGELOG.md

更新履歴

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.6.0 (2022-02-10)

⚠ BREAKING CHANGES

  • setFailed only accepts Error for reason, exported types are simplified

Features

  • add getFailReason to wait return (8ff1c59)

0.5.6 (2021-11-02)

Bug Fixes

  • deps: update jest, ts-jest to v27 (2329823)
  • use never but not unknown for generic function arguments type in withReady() (a060ddd)

0.5.5 (2021-04-12)

Bug Fixes

  • export waitFor() in index (082d37c)

0.5.4 (2021-04-11)

Features

  • add waitFor() for polling check ready status (3fc5e2d)

0.5.3 (2021-03-29)

Bug Fixes

  • add babel plugin to rollup to ensure es5 format foor bundle.js (154b5bb)

0.5.2 (2021-03-10)

Features

0.5.1 (2021-01-29)

Features

  • support set a name for waiting task (0ce972b)

0.5.0 (2020-03-14)

⚠ BREAKING CHANGES

  • method/type names are changed: beginWait() -> wait(); wait() -> afterReady()

Features

  • use generic type for result value (f7a938c)