Zebra API Doc

zebra.util.task

task

(
  • f
  • [ctx]
)
zebra.util.Task

Take a free task from pool and run it with the specified body and the given context.

   // allocate task 
   var task = zebra.util.task(function (ctx) {
       // do something 

       // complete task if necessary 
       ctx.shutdown();
   });

   // run task in second and re-run it every 2 seconds
   task.run(1000, 2000);

   ...

   // pause the task
   task.pause();

   ...
   // run it again 
   task.run();

Parameters:

  • f Function | Object

    a function that has to be executed

  • [ctx] Object optional

    a context the task has to be executed


Return: zebra.util.Task

an allocated task