in my module’s constructor I want to load configuration data for the module. The idea is that this data is being fetched from the blockchain itself, hence the approach to load it from stateStore. In case, there is no data in the stateStore yet (no transaction processed yet which would have set stateStore data), some default configuration shall be used.
To invoke getChainState at all, one needs to pass the stateStore as an argument, that’s why I can’t invoke in the constructor. Your recommendation to return the default config in the if-block is a welcomed addition, but it does not solve my issue.
I had the beforeBlockApply() method in mind, but this seems like a bad practice, because whichever code block I am adding is executed on every block forever. The same would be for a routine implemented on every reducer … it would work but seems wrong.
I wonder what the reasoning was / is to let a module access stateStore in reducers and lifecycle hooks but not its constructor.
Loading module configuration from the chain itself is a weird thing to do.
Modules are on-chain logics, so the only behaviours supposed to be affected by on-chain configuration are block lifecycles, reducers and assets (aka custom transactions).
All those things have access to the stateStore.
If you want to configure something else from the chain itself, it’s most likely wrong.