@wpazderski/js-utils
    Preparing search index...

    Class Registry<TKey, TValue>

    A generic registry class that allows registering, unregistering, and retrieving entries by their keys.

    Type Parameters

    • TKey extends RegistryEntryKey

      The type of the entry key, which should extend RegistryEntryKey.

    • TValue

      The type of the entry value.

    Index

    Constructors

    Properties

    baseRegistry: undefined | Registry<TKey, TValue> = undefined

    The base registry from which this registry derives entries. If provided, this registry will inherit entries from the base registry. It will also register itself as a derived registry of the base registry. This allows for hierarchical registries where derived registries can extend or override entries from the base registry.

    entryOverriddenCallbacks: Callbacks<EntryOverriddenCallback<TKey, TValue>> = ...

    Callbacks for when an entry is overridden.

    entryRegisteredCallbacks: Callbacks<EntryRegisteredCallback<TKey, TValue>> = ...

    Callbacks for when an entry is registered.

    entryUnregisteredCallbacks: Callbacks<EntryUnregisteredCallback<TKey>> = ...

    Callbacks for when an entry is unregistered.

    Options for configuring the registry.

    Methods

    • Iterates over all entries in the registry and calls the provided callback function for each entry.

      Parameters

      • callback: (entry: TValue, entryKey: TKey) => void

        A function that will be called for each entry in the registry. The callback receives two parameters: value and key of current entry.

      Returns void

    • Retrieves an entry from the registry by its key. If the entry key does not exist, it returns undefined.

      Parameters

      • entryKey: TKey

        The key for the entry to retrieve.

      Returns undefined | TValue

      The value of the entry if found, otherwise undefined.

    • Checks if an entry with the specified key exists in the registry.

      Parameters

      • entryKey: TKey

        The key for the entry to check.

      Returns boolean

      True if the entry exists, otherwise false.

    • Core method for registering an entry in the registry. This method is called by the public register and registerOrOverride methods. It does not check if the entry key already exist.

      Parameters

      • entryKey: TKey

        The key for the entry to register.

      • entry: TValue

        The value of the entry to register.

      Returns void

    • Registers or overrides an existing entry in the registry. If the entry key does not exist, it will be registered. If the entry key already exists, it will override the existing entry without throwing an error.

      Parameters

      • entryKey: TKey

        The key for the entry to register or override.

      • entry: TValue

        The value of the entry to register or override.

      Returns void

    • Core method for unregistering an entry from the registry. This method is called by the public unregister and unregisterIfRegistered methods.

      Parameters

      • entryKey: TKey

        The key for the entry to unregister.

      Returns void

    • Unregisters an entry from the registry if it is registered. If the entry key does not exist, it does nothing.

      Parameters

      • entryKey: TKey

        The key for the entry to unregister if registered.

      Returns void