You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid circular dependencies where Application has ref to container and container contains application
Why do we need application in container?
We are getting settings from application to find out if schema validation has been enabled. But maybe we can instead create a settings component and then only add that component to Container.
2.We can potentially inject the Application component with @Inject decorator into any component. But why and what are we achieving. It may have something to do with hot reloading of container.
For hot reloading or hot adding a new component we need to do component scan, add a new component to container and then do we need to add new container to Application? If we do then yes, we need a way to grab ahold of the Application from component like from Controller. But there should be a better way.
Right now in application we have this code in handleRequest method:
const handlerPromise = this.middlewares.reduce((prev, next) => {
return prev.then(next);
}, Promise.resolve(ctx));
This means that we need access to sorted array of middlewares that we currently set in Application in this.middlewares = getMiddlewares(container);
Also setupRoutes(container); inside Application uses setupRouter function and it does not need access to Application, so this can be done outside of Application, possibly in some type of stand-alone initializer function.
First, can we do something like in React where they inject Application Context and you can grab ahold of context somehow?
Second, maybe we can just NOT REPLACE the create container with another one, maybe we can just reload the components and re-initialize existing container. That would be better.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Avoid circular dependencies where Application has ref to container and container contains application
Why do we need application in container?
2.We can potentially inject the Application component with @Inject decorator into any component. But why and what are we achieving. It may have something to do with hot reloading of container.
For hot reloading or hot adding a new component we need to do component scan, add a new component to container and then do we need to add new container to Application? If we do then yes, we need a way to grab ahold of the Application from component like from Controller. But there should be a better way.
Right now in application we have this code in handleRequest method:
const handlerPromise = this.middlewares.reduce((prev, next) => {
return prev.then(next);
}, Promise.resolve(ctx));
This means that we need access to sorted array of middlewares that we currently set in Application in this.middlewares = getMiddlewares(container);
Also setupRoutes(container); inside Application uses setupRouter function and it does not need access to Application, so this can be done outside of Application, possibly in some type of stand-alone initializer function.
First, can we do something like in React where they inject Application Context and you can grab ahold of context somehow?
Second, maybe we can just NOT REPLACE the create container with another one, maybe we can just reload the components and re-initialize existing container. That would be better.
The text was updated successfully, but these errors were encountered: