nextTick

Add a callback to the "next tick queue".

Usage

var nextTick = require( '@stdlib/utils/next-tick' );

nextTick( clbk[, ...args] )

Adds a callback to the "next tick queue".

function beep() {
    console.log( 'boop' );
}

nextTick( beep );

Notes

  • The queue is fully drained after the current operation on the JavaScript stack runs to completion and before the event loop is allowed to continue.
  • Creating an infinite loop is possible if nextTick is called recursively.

Examples

var nextTick = require( '@stdlib/utils/next-tick' );

function beep( x, y, z ) {
    console.log( 'boop: %d %d %d', x, y, z );
}

nextTick( beep, 1, 2, 3 );
Did you find this page helpful?