enqueue
Enqueue a function to be called.
queue.enqueue(fn, context, args, meta)
Enqueues the fn
function to be called with context
as this
and args
as its arguments.
queue.enqueue( console.log, console, [ "say hi" ], {} );
queue.flush();
// console.logs "say hi"
Tasks are enqueued at the end of the queue. If the queue's tasks are currently
being flushed, new tasks added will be run without needing to call .flush
.
When the first task is enqueued, the onFirstTask
callback is called.
Parameters
- fn
{function}
:The function to be called.
- context
{Any}
:The
this
the function is called with. - args
{Array|Arguments}
:The arguments the function is called with.
- meta
{Object|undefined}
:Additional information useful for debugging. log will use:
- log
{Array}
: An array of values that will be passed toconsole.log
when this task is enqueued or flushed. By default it is[fn.name]
. - reasonLog
{Array}
: An array of values that could be passed toconsole.log
representing why this task was scheduled.
- log