Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TrackedRegistry<T>

A tracked registry provides a wrapper to automatically track registrations made by your script in some other registry. By registering something through a tracked registry, the wrapper will automatically keep track of what is currently registered and allow all registered entities to be unregistered automatically (for example, when a plug-in is unloaded). Other classes in the library build on this base class.

Type parameters

  • T

Hierarchy

  • TrackedRegistry

Index

Constructors

constructor

  • Creates a new tracked registry. The only restriction on the registration function is that it requires at least one argument, which is used to track the registration. The unregistration function must be able to unregister the entity using the entity parameter alone.

    Parameters

    • registerFn: CallableFunction

      a function that can be called to register a new entity

    • unregisterFn: CallableFunction

      a function that can be called to unregister an entity

    Returns TrackedRegistry

Methods

register

  • register(entity: T, ...moreArguments: any[]): void
  • Registers some entity in the wrapped registry by calling the registration function with the provided arguments. The resuly of registering the same entity multiple times is undefined.

    Parameters

    • entity: T

      the argument that uniquely identifies the registered object; usually a handler function

    • Rest ...moreArguments: any[]

      additional arguments passed to the registration function

    Returns void

unregister

  • unregister(entity: T): void
  • Unregisters a previously registered entity by calling the unregister function with the provided entity.

    Parameters

    • entity: T

      the entity to be unregistered, as passed to register

    Returns void

unregisterAll

  • unregisterAll(): void
  • Unregisters all tracked entities.

    Returns void