This block provides an object for working with a regularly generated tick event (to implement the polling pattern).
| Name | Description |
|---|---|
| tick | A regularly generated event. |
| Name | Return type | Description |
|---|---|---|
| start() | - | Starts generating tick events if the process hasn't started yet. |
| stop() | - | Stops generating tick events if the process hasn't stopped yet. |
| Modifier | Acceptable values | Usage | Description |
|---|---|---|---|
| start | 'auto' |
JS |
Automatically starts generating events |
The block is implemented in:
vanilla.jstick eventSubscribe to the event to use it to implement the polling pattern.
An event is generated every 50 milliseconds.
The block is a descendant of the Emitter class in the events block, which allows it to call these classes.
modules.require('tick', function(tick) {
var update = function() { /* ... */ };
tick
.on('tick', update) // subscribing to the tick event
.start(); // starting generation of tick events
});
start methodStarts generating tick events if the process hasn't started yet. A tick is generated with an interval of 50 milliseconds after invoking the method.
Doesn't accept arguments.
No return value.
stop methodStops generating tick events.
Doesn't accept arguments.
No return value.
start modifierAcceptable values: 'auto'.
Usage: JS.
Use the block with the start modifier set to auto in order to automatically start generating tick events. The event starts being generated at the time of block initialization.