Constructor
new ProcessRegistry(processesopt, addNamespaceopt)
Creates a new registry of all processes.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
processes |
Array.<object> | ProcessRegistry |
<optional> |
[] | Optionally, a list of predefined processes. |
addNamespace |
boolean |
<optional> |
false | Add a namespace property to processes if set to `true`. |
- Source:
Members
(protected) addNamespace :boolean
Add a namespace property to processes if set to `true`.
Type:
- boolean
- Source:
listeners
List of listeners for change events.
- Source:
(protected) processes :object.<string, object.<string, object>>
Object of namespaces and processes.
Type:
- object.<string, object.<string, object>>
- Source:
Methods
add(processes, namespaceopt)
Adds a single process to a given namespace.
Replaces an existing process in the given namespace if it exists.
Fires 'add' event.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
processes |
object | A process definition | ||
namespace |
string |
<optional> |
"backend" | The namespace for the process (defaults to 'backend', i.e. pre-defined processes) |
- Source:
addAll(processes, namespaceopt)
Adds a list of processes for a given namespace.
Replaces an existing process in the given namespace if it exists.
Fires 'addAll' event.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
processes |
Array.<object> | Optionally, a list of processes | ||
namespace |
string |
<optional> |
"backend" | The namespace for the processes (defaults to 'backend', i.e. pre-defined processes) |
- Source:
all() → {Array.<object>}
Returns all processes as a list, independant of the namespaces.
- Source:
Returns:
- Type
- Array.<object>
count() → {number}
Returns the count of all processes independant of the namespaces.
- Source:
Returns:
- Type
- number
get(id, namespaceopt, nullable) → {object}
Retrieve the process with the given ID fron the given namespace.
If the namespace is set to `null` (default) then it retrieces from both (1) `user` processes and (2) `backend` processes
with preference to user processes on conflict. The default namespace for pre-defined processes is `backend`.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | The process identifier | ||
namespace |
string |
<optional> <nullable> |
null | The namespace of the process |
- Source:
Returns:
- Type
- object
has(id, namespaceopt, nullable) → {boolean}
Checks whether a process with the given ID exists in the given namespace.
If the namespace is set to `null` (default) then it checks both user processes and backend processes.
The default namespace for pre-defined processes is `backend`.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | The process identifier | ||
namespace |
string |
<optional> <nullable> |
null | The namespace of the process |
- Source:
Returns:
- Type
- boolean
hasNamespace(namespace) → {boolean}
Checks whether a namespace exists (i.e. at least one process for the namespace exists)
Parameters:
Name | Type | Description |
---|---|---|
namespace |
string | The namespace |
- Source:
Returns:
- Type
- boolean
namespace(namespace) → {Array.<object>}
Returns all processes from a specific namespace.
Returns an empty list if the namespace is not defined.
Parameters:
Name | Type | Description |
---|---|---|
namespace |
string | The namespace of the processes to return (e.g. 'backend' for pre-defined processes) |
- Source:
Returns:
- Type
- Array.<object>
namespaces() → {Array.<string>}
Returns a (sorted) list of all available namespaces.
- Source:
Returns:
- Type
- Array.<string>
onChange(event, data, namespace)
Event that is fired on changes, notifies listeners.
Parameters:
Name | Type | Description |
---|---|---|
event |
string | One of 'add', 'addAll' or 'remove'. |
data |
* | |
namespace |
string |
- Source:
remove(idopt, nullable, namespaceopt, nullable) → {boolean}
Removes a single process or a complete namespace from the registry.
If nothing is given, removes the namespace 'user'.
If only a namespace is given, removes the whole namespace.
If only a process is given, removes a process from the namespace `user`.
If both parameters are given, removes a process from the given namespace.
Returns `true` on succes, `false` on failure.
Fires 'remove' event.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string |
<optional> <nullable> |
null | The process identifier |
namespace |
string |
<optional> <nullable> |
"user" | The namespace, defaults to `user` |
- Source:
Returns:
- Type
- boolean