xamples
epeat
ode
pproach
ptimize
est
// To implement the 'eventQueue' you can use an array
// be sure to mimic a queue by only using '.shift()'
let eventQueue = [ ];
// ensure the event loop keeps going "forever"
while (true) {
// perform a "tick"
if (eventQueue.length > 0) {
// get the next event in the queue
let event = eventQueue.shift();
// now, execute the next event
//this try/catch block does all of the checks to ensure
//that the event is a function that can run appropriately
try {
event();
}
catch (err) {
reportError(err);
}
}
}
//You can, but do not need to mimic pushing to the eventQueue