Skip to content

LosMaquios/next-tick

Repository files navigation

NextTick

Flush your callbacks on the next event loop tick

Installation

From CDN:

import nextTick from 'https://cdn.jsdelivr.net/gh/LosMaquios/next-tick/index.js'

From NPM:

$ npm install next-tick

Usage

nextTick(() => {
  console.log(' deferred')
})

console.log('Execution')

// Output: Execution deferred

API Reference

nextTick(callback)

Defers execution of a given callback

nextTick.waiting

A boolean indicating when we are waiting to flush callbacks

nextTick.queue

An array containing callbacks to be flushed

nextTick.flush()

Flush callbacks as a single microtask

nextTick.afterFlush(callback)

Execute (as a macrotask) a callback after flushing the queue