Skip to main content

Class: Registry

Registry is a static factory that handles registration/reconstruction of classes bases on BaseClass. Registered classes can then be constructed by the Registry by name.

Note: className is required because on minification process the name of classes change and we can't simply use '....constructor.name'. So, we need a way of relating minified class names to the one stored for persistency.

i.e.

// Import registry classclass Foo() extends BaseClass {}
Registry.register('Foo', Foo)// In case 'Foo' class gets its name changed to 'c' on minification,// and the persisted data type is 'Foo', we would know how to relate them.

static

Constructors#

constructor#

new Registry()

Methods#

constructClass#

Static constructClass(className): BaseClass

The factory function that construct the class registered under the given name.

Parameters#

NameTypeDescription
classNamestringName of the registered class

Returns#

BaseClass

  • Instantiated object of the specified class

Defined in#

Registry.ts:78


flush#

Static Private flush(): void

For testing purpose only, never call this outside of the test scope.

Returns#

void

Defined in#

Registry.ts:90


getClassDefinition#

Static getClassDefinition(className): typeof BaseClass

Returns class definition using the name it was registered with.

Parameters#

NameTypeDescription
classNamestringName of the registered class

Returns#

typeof BaseClass

  • Class representation(Class function, type)

Defined in#

Registry.ts:55


getClassName#

Static getClassName(classDefinition): string

Returns class name registered for the instantiated object.

Parameters#

NameTypeDescription
classDefinitiontypeof BaseClassClass type definition.

Returns#

string

  • Name of the registered class

Defined in#

Registry.ts:65


register#

Static register(className, classDef): void

Registers a new class to the factory.

Parameters#

NameTypeDescription
classNamestringName of the registered class
classDeftypeof BaseClassClass representation(Class function, type)

Returns#

void

Defined in#

Registry.ts:36