Options
All
  • Public
  • Public/Protected
  • All
Menu

Class manager allowing for dynamically changing which class definitions are used. Allows for defining a default set of classes which can later be overwritten without special changes to the code.

Type parameters

  • T

  • R

Hierarchy

  • ClassManager

Index

Constructors

constructor

  • new ClassManager<T, R>(DefaultCls?: T): ClassManager<T, R>

Properties

Optional DefaultCls

DefaultCls: T

classes

classes: Record<string, T>

Methods

getByKey

  • getByKey(key: string): null | T
  • Retrieve the class definition based on the key.

    Parameters

    • key: string

      Key used to identify the purpose for the class.

    Returns null | T

newFromKey

  • newFromKey(key: string, ...args: any): null | R
  • Create a new instance of a registered class if available.

    Falls back to the default class if it is defined or returns null if no matching class definition is found.

    Parameters

    • key: string

      Key used to identify the purpose for the class.

    • Rest ...args: any

      Arguments to be passed onto the class constructor.

    Returns null | R

registerClass

  • registerClass(key: string, Cls: T): void
  • Register a new class that will be used when creating a new class based on the provided key.

    Parameters

    • key: string

      Key used to identify the purpose for the class.

    • Cls: T

      Class definition to use for the given key.

    Returns void

registerClasses

  • registerClasses(classes: Record<string, T>): void
  • Register multiple classes as a time.

    Parameters

    • classes: Record<string, T>

      A mapping of keys to class definitions.

    Returns void

Generated using TypeDoc