classregistry
Source: registry.
new registry(evt_list)
Contructor for BBOP registry. Takes a list of event categories as strings.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
evt_list |
Array |
|
a list of strings that identify the events to be used |
- Returns
-
Object
bbop registry object
Methods
apply_callbacks(category, arg_list[, context])
Generic runner for prioritized callbacks with various arguments and an optional change in context..
Parameters
Name | Type | Optional | Description |
---|---|---|---|
category |
String |
|
string |
arg_list |
Array |
|
a list of arguments to pass to the function in the category |
context |
String |
Yes |
the context to apply the arguments in |
get_callbacks(category) → Array
Generic getter for callback functions, returns by priority.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
category |
String |
|
string |
- Returns
-
Array
an ordered (by priority) list of function_id strings
is_registered(category, function_id) → (Boolean or null)
Returns whether or not an id has already been registered to a category. Will return null if the category does not exist.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
category |
String |
|
one of the pre-defined categories |
function_id |
String |
|
a unique string to identify a function |
- Returns
-
(Boolean or null)
true, false, or null
register(category, in_function[, in_priority][, function_id]) → String
Add the specified function from the registry, with an optional relative priority against other callback functions.
The in_priority value is relative to others in the category, with a higher priority...getting priority.
See also:
Parameters
Name | Type | Optional | Description |
---|---|---|---|
category |
String |
|
one of the pre-defined categories |
in_function |
function() |
|
function |
in_priority |
Number |
Yes |
the higher the faster |
function_id |
String |
Yes |
a unique string to identify a function; generated if one is not given |
- Returns
-
String
the ID for the registered function in the given category
unregister(category, function_id) → Boolean
Remove the specified function from the registry. Must specify a legitimate category and the function id of the function in it.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
category |
String |
|
string |
function_id |
String |
|
string |
- Returns
-
Boolean
boolean on whether something was unregistered