new SignalBox()
Coordinates Promises corresponding to different stages in the loading process.
Methods
getCallback(name) → {Numbas.schedule.callback}
Get a callback object for the event with the given name. If the callback hasn't been accessed before, it's created.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Returns:
Type | Description |
---|---|
Numbas.schedule.callback |
halt(error)
Halt this signal box because of an error: reject all outstanding promises.
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | The error that caused the signal box to halt. |
on(events, fnopt) → {Promise}
Once the given event(s) have resolved, run the given callback function. Returns a Promise, so can be used without a callback.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
events |
string | Array.<string> | The name of an event, or a list of event names. |
|
fn |
function |
<optional> |
A callback function to run. |
Returns:
Type | Description |
---|---|
Promise |
Resolves when all of the events have resolved, or rejects if the signal box is in an error state. |
trigger(name)
Notify the signal box that the event with the given name has happened.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
unhalt()
Unhalt this signal box: allow promises to be made again.