-
Notifications
You must be signed in to change notification settings - Fork 1
HaxeVX Vuex dynamic module registration
Currently in repository, there is some very basic (single-level) dynamic module registration/unregistration support available. This is currently used in production.
For pathed chained (array-based) implicit (in-between) dynamic module registration that can occur recursively, some changes must be done to codebase to allow dynamic auto-instantation of modules without having to supply an explicit module instance reference.
eg. If i register a module along a path of moduleA/nestedModuleB/anotherNestedModule/yetAnotherOne
, either ALL or the in-between modules can be automatically instantiated (if those modules aren't available yet), depending on what VxBoot function i used to facilitate the booting of those modules.
These are:
With @:manual
metadata on @:module
, will always add matching runtime @module
metadata to the class field which always contains runtime class name identifier or factory method reference (if provided in @:module
) to help auto-provide an instance of the given module class in the event no explicit module instance is provided during registration of modules and the module isn't instantiated yet. An instance-based factory method call with explicit matching return data type is generated within the Store/Module class to facilitate the creation of such a module and provide compile-time type checking within Haxe.
Can contain factory method reference to facilitate default method of instantiation of module.
Examples can be like:
@:module( factoryMethodToExecute(323,232,232) )
, or @:module( yetAnotherFactoryMethod() )
A instance based method on the store/module class will be generated that will return that given function call expression. Thus, type checking is available at compile time to determine the validity of the expression, even though the module is dynamically instantiated at runtime with their respective runtime metadata reference.
Some common usage could be, it's possible to dynamically auto-instantiate a module based off the current store/module's state.
@:module( yetAnotherFactoryMethod(state.spawnSettings.a, state.spawnSettings.b) )