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.
#
ParametersName | Type | Description |
---|---|---|
className | string | Name of the registered class |
#
Returns- Instantiated object of the specified class
#
Defined in#
flush▸ Static
Private
flush(): void
For testing purpose only, never call this outside of the test scope.
#
Returnsvoid
#
Defined in#
getClassDefinition▸ Static
getClassDefinition(className
): typeof BaseClass
Returns class definition using the name it was registered with.
#
ParametersName | Type | Description |
---|---|---|
className | string | Name of the registered class |
#
Returnstypeof BaseClass
- Class representation(Class function, type)
#
Defined in#
getClassName▸ Static
getClassName(classDefinition
): string
Returns class name registered for the instantiated object.
#
ParametersName | Type | Description |
---|---|---|
classDefinition | typeof BaseClass | Class type definition. |
#
Returnsstring
- Name of the registered class
#
Defined in#
register▸ Static
register(className
, classDef
): void
Registers a new class to the factory.
#
ParametersName | Type | Description |
---|---|---|
className | string | Name of the registered class |
classDef | typeof BaseClass | Class representation(Class function, type) |
#
Returnsvoid