Struct
Type parameters
▪ T: SuperConstructor
▪ T: SuperConstructor
Hierarchy
SuperPrototypeSelector‹DefinableMixin | HookableMixin, this› & DefinableMixin‹this› & HookableMixin‹this›
SuperPrototypeSelector‹DefinableMixin | HookableMixin, this› & DefinableMixin‹this› & HookableMixin‹this›
↳ Struct
↳ Config
Implements
Index
Constructors
Methods
- equals
- getActions
- getHook
- getHookOrThrow
- getHooks
- getPropTypes
- getPropertyInitializers
- hasAction
- hasHook
- overrideHook
- registerHook
- removeHook
- toPlainObject
- validateProps
- getPropTypes
- getPropertyInitializers
Constructors
constructor
+ new Struct(props?
: Props): Struct
Creates an instance of Struct. Creates an instance of Struct.
throws
{UndefinableClassError}
Thrown if provided class constructor has no @define
decorator applied.
remarks
Property initializers on current implementation of TypeScript v3.7 are counterintuitive
when inheritance is involved:
Normally in such cases developer expects, that - since underlying parent of
MyClass
i.e. Struct
class assings properties via Object.assign
- they will
override the default values of property initializer(so the default-value
will be
overridden by set-value
).
However since MyClass
does not override constructor - that will not happen.
This will instantiate MyClass
with the default-value
, and not the
expected one - set-value
.
Conclusion from this is that property initializers are set AFTER the
construction - not before(where inhabitance is in play).
To fix this issue - define custom constructor for derived class:
throws
{UndefinableClassError}
Thrown if provided class constructor has no @define
decorator applied.
remarks
Property initializers on current implementation of TypeScript v3.7 are counterintuitive
when inheritance is involved:
Normally in such cases developer expects, that - since underlying parent of
MyClass
i.e. Struct
class assings properties via Object.assign
- they will
override the default values of property initializer(so the default-value
will be
overridden by set-value
).
However since MyClass
does not override constructor - that will not happen.
This will instantiate MyClass
with the default-value
, and not the
expected one - set-value
.
Conclusion from this is that property initializers are set AFTER the
construction - not before(where inhabitance is in play).
To fix this issue - define custom constructor for derived class:
Parameters:
Name | Type | Description |
---|---|---|
props? | Props | Properties of the type required for construction. |
Returns: Struct
Methods
equals
▸ equals(other
: any): boolean
Implementation of Definable
Inherited from DefinableMixin.equals
Overrides CreateEmployee.equals
Parameters:
Name | Type |
---|---|
other | any |
Returns: boolean
getActions
▸ getActions(): Actions
Implementation of Hookable
Inherited from HookableMixin.getActions
Overrides CreateEmployee.getActions
Returns: Actions
getHook
▸ getHook(action
: string, id
: string): Hook | undefined
Implementation of Hookable
Inherited from HookableMixin.getHook
Overrides CreateEmployee.getHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: Hook | undefined
getHookOrThrow
▸ getHookOrThrow(action
: string, id
: string): Hook
Implementation of Hookable
Inherited from HookableMixin.getHookOrThrow
Overrides CreateEmployee.getHookOrThrow
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: Hook
getHooks
▸ getHooks(action
: string): Mappings
Implementation of Hookable
Inherited from HookableMixin.getHooks
Overrides CreateEmployee.getHooks
Parameters:
Name | Type |
---|---|
action | string |
Returns: Mappings
getPropTypes
▸ getPropTypes(): Props
Implementation of Definable
Inherited from DefinableMixin.getPropTypes
Overrides CreateEmployee.getPropTypes
Returns: Props
getPropertyInitializers
▸ getPropertyInitializers(): Props
Implementation of Definable
Inherited from DefinableMixin.getPropertyInitializers
Overrides CreateEmployee.getPropertyInitializers
Returns: Props
hasAction
▸ hasAction(action
: string): boolean
Implementation of Hookable
Inherited from HookableMixin.hasAction
Overrides CreateEmployee.hasAction
Parameters:
Name | Type |
---|---|
action | string |
Returns: boolean
hasHook
▸ hasHook(action
: string, id
: string): boolean
Implementation of Hookable
Inherited from HookableMixin.hasHook
Overrides CreateEmployee.hasHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: boolean
overrideHook
▸ overrideHook(action
: string, id
: string, hook
: Hook): void
Implementation of Hookable
Inherited from HookableMixin.overrideHook
Overrides CreateEmployee.overrideHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
hook | Hook |
Returns: void
registerHook
▸ registerHook(action
: string, id
: string, hook
: Hook, shouldOverride?
: boolean): void
Implementation of Hookable
Inherited from HookableMixin.registerHook
Overrides CreateEmployee.registerHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
hook | Hook |
shouldOverride? | boolean |
Returns: void
removeHook
▸ removeHook(action
: string, id
: string): void
Implementation of Hookable
Inherited from HookableMixin.removeHook
Overrides CreateEmployee.removeHook
Parameters:
Name | Type |
---|---|
action | string |
id | string |
Returns: void
toPlainObject
▸ toPlainObject(): Props
Implementation of Definable
Inherited from DefinableMixin.toPlainObject
Overrides CreateEmployee.toPlainObject
Returns: Props
validateProps
▸ validateProps(props
: Record‹string | number | symbol, any› | undefined, propTypes
: PropTypes, isStrict?
: boolean): boolean
Inherited from DefinableMixin.validateProps
Overrides CreateEmployee.validateProps
Parameters:
Name | Type |
---|---|
props | Record‹string | number | symbol, any› | undefined |
propTypes | PropTypes |
isStrict? | boolean |
Returns: boolean
Static
getPropTypes
▸ getPropTypes(): Props
Inherited from DefinableMixin.getPropTypes
Overrides CreateEmployee.getPropTypes
Returns: Props
Static
getPropertyInitializers
▸ getPropertyInitializers(): Props
Inherited from DefinableMixin.getPropertyInitializers
Overrides CreateEmployee.getPropertyInitializers
Returns: Props