Creates a new instance of the Registry class.
The name of the registry.
Optional
idField: string = 'id'The field to use as the ID of items in the registry.
Optional
mode: RegistryModes = Registry.MODES.CLEANThe mode of the registry.
The items that are currently banned.
The field to use as the ID of items in the registry.
The mode of the registry.
The name of the registry.
The items that are currently protected.
The items that are currently registered.
The subscribers to the registry.
The items that are currently unregistered.
Static
MODESAn enumeration of the modes that a registry can be in.
Gets the banned items in the registry.
The banned item ids.
Gets the mode of the registry.
The mode of the registry. This will be one of the following: Registry.MODES.HISTORY
, Registry.MODES.CLEAN
.
Sets the mode of the registry.
The new mode. This should be one of the following: Registry.MODES.HISTORY
, Registry.MODES.CLEAN
. If it's not, the mode will be set to Registry.MODES.CLEAN
.
Gets the protected items in the registry.
The protected item ids.
Gets the unregistered items in the registry.
The unregistered item ids.
Bans an item in the registry.
The ID of the item to ban.
The registry instance.
Notification of type NotificationTypes.BAN When an item is banned.
This method adds the item to the banned list. If the registry is in Registry.MODES.CLEAN mode, the cleanup method is also called to remove the item from the registry and perform any necessary cleanup operations.
Cleans up an item in the registry. Item is permanently removed.
The ID of the item to clean up.
The registry instance.
Notification of type NotificationTypes.CLEANUP When an item is cleaned up.
This method is responsible for removing the item from the registry and performing any necessary cleanup operations. It is called when an item is unregistered and the registry is in Registry.MODES.CLEAN mode.
Flushes the registry.
The registry instance.
Notification of type NotificationTypes.FLUSH When the registry is flushed.
This method is responsible for removing all items from the registry, clearing the protected, unregistered, and banned lists.
Retrieves an item from the registry by its path.
The path of the item to retrieve. The first element of the path is the ID of the item.
Optional
defaultValue: TThe default value to return if the item does not exist.
The item with the given path, or the default value if no such item exists.
Sends a notification to all subscribed callback functions.
The notification to send.
Protects an item in the registry from being unregistered.
The ID of the item to protect.
The registry instance.
Notification of type NotificationTypes.PROTECT When an item is protected.
Registers an item in the registry with the provided ID.
The ID of the item to register.
The item to register.
The registry instance.
If the item is banned or if a protected item is already registered.
Notification of type NotificationTypes.REGISTER When an item is registered.
Registers an item in the registry with an ID generated by the registry.
The item to register.
The registry instance.
If the item is banned or if a protected item is already registered.
Notification of type NotificationTypes.REGISTER When an item is registered.
Subscribes a callback function to notifications from the registry.
The callback function to subscribe.
Optional
id: stringThe ID to associate with the subscription. If not provided, a new UUID will be generated.
A function that, when called, will unsubscribe the callback function from the registry.
Removes ban on an item in the registry.
The ID of the item to ban.
The registry instance.
Notification of type NotificationTypes.BAN When an item is banned.
This method removes the item to the banned list.
Removes protection from an item in the registry.
The ID of the item to unprotect.
The registry instance.
Notification of type NotificationTypes.UNPROTECT When an item is unprotected.
Unregisters an item from the registry.
The ID of the item to unregister.
The registry instance.
If the item is protected.
Notification of type NotificationTypes.UNREGISTER When an item is unregistered.
If the registry is in Registry.MODES.CLEAN, the item is immediately removed and the cleanup method is called. If the registry is in Registry.MODES.DEFAULT, the item is marked for unregistration but not immediately removed.
Subscribes a callback function to notifications from the registry.
Optional
id: stringThe ID to associate with the subscription. If not provided, a new UUID will be generated.
A function that, when called, will unsubscribe the callback function from the registry.
Registry
Param: name
The name of the registry.
Param: idField
The field to use as the ID of items in the registry.
Param: mode
The mode of the registry.