Rename to postConstruct
all methods decorated with the @postConstruct()
decorator
#10700
Labels
quality
issues related to code and application quality
postConstruct
all methods decorated with the@postConstruct()
decorator.() => void
.There are a lot of inconsistencies when it comes to this post-constructor callback method. most of the time the method is called
init
, but sometimesconfigure
, orinitialize
. I would prefer to call itpostConstruct
as it better describes what the method is meant for, but sinceinit
is most commonly used I would be OK with renaming to this instead.Inversify's
postConstruct
exist because when it tries to create the instances for our bindings, it has to call the constructor before it can inject properties (if any). See the following example:A problem in our code base is that some of those
postConstruct
functions return promises. Inversify won't wait on them, as the instance creation step assumes everything happens synchronously. This means that more often than not, by the time our asynchronously-post-constructed services are injected, dependents might try to call into uninitialized properties...The text was updated successfully, but these errors were encountered: