Dispatcher
Offers functionality to call timed callbacks. Generally this requires a UI framework to be active such as a Game.GameWindow or Nori.Frame. However, events can be manually dispatched by calling Dispatcher.flush() from synchronous code.
- namespace Dispatcher
function flush()[link]
Causes all the callbacks that are due to run to get invoked. The dispatcher will automatically invoke the callbacks in situations where there is an active UI such as a Game window or Nori frame and so calling this function is unnecessary in those types of programs. However in synchronous programs, such as single-threaded command line programs, the VM is unable to interrupt the current thread to do so, and so this function ought to be called periodically in those situations if setTimedCallback and setRecurringCallback are used.
function setRecurringCallback(callback, delay, arguments)[link]
Invokes a given function repeatedly with the given interval duration.
Arguments
Name | Type | Optional | Description |
---|---|---|---|
callback | function | A function pointer to invoke. |
|
delay | float | Number of seconds to wait before invoking the function pointer since the last time the function was invoked. Note that this is the time since the function was invoked and not since the function previously ended. |
|
arguments | list | Optional | A list of arguments to pass to the function. If not specified, the function will be invoked with no arguments. |
function setTimedCallback(callback, delay, arguments)[link]
Invokes a given function after a given amount of time has passed. The function is only invoked once.
Arguments
Name | Type | Optional | Description |
---|---|---|---|
callback | function | A function pointer to invoke. |
|
delay | float | Number of seconds to wait before invoking the function pointer. |
|
arguments | list | Optional | A list of arguments to pass to the function. If not specified, the function will be invoked with no arguments. |