Timers

  1. setInterval(callback, delay, [arg], [...])

    setInterval(function(){
       console.log('test');
    }, 60 * 60 * 1000);
    
  2. To schedule the repeated execution ofcallbackeverydelaymilliseconds. Returns aintervalId

    for possible use withclearInterval()

    Optionally you can also pass arguments to the callback.setTimeout(callback, delay, [arg], [...])

     To schedule execution of a one-time`callback`after`delay`milliseconds.
    
     This function Returns a`timeoutId`for possible use with`clearTimeout() `callback. It is important to note that your callback will probably not be called in exactly`delay`milliseconds - Node.js makes no guarantees about the exact timing of when the callback will fire, nor of the ordering things will fire in. The callback will be called as close as possible to the time specified.
    
  3. clearImmediate(immediateObject)

this method Prevents a timeout from triggering. it basically clear the immediateObjext reference passed to it.

Using The timer module:

Thetimermodule exposes a global API for scheduling functions to be called at some future period of time. Because the timer functions are globals, there is no need to call

require('timers')

to use the API.

A timer in Node.js is an internal construct that calls a given function after a certain period of time. When a timer's function is called varies depending on which method was used to create the timer and what other work the Node.js event loop is doing.

results matching ""

    No results matching ""