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
The problem is the GrandParent controller will be allocated twice, meaning c.Parent1.GrandParent != c.Parent2.GrandParent. The output of the GrandParent's Before will be:
This is GrandParent
This is GrandParent
As a result, we cannot share a context between controllers of different levels of embedding.
Use-case
This is the problem I've faced trying to implement #39. There is controllers/errors controller that is responsible for rendering error pages. We embed it in our main controller and mount its actions to * /errors:
Because, Context of Controllers and Context of Errors are different instances. But they must be pointers to the same object.
Expectations
A single allocation per object per request. Special (Before and After) actions must be called just once: Parents must have priority over their Children.
The text was updated successfully, but these errors were encountered:
I'm thinking over this one as well. Should we allocate controllers? Isn't it too much magic? Especially when it comes to these single allocation rules. Can we come up with another solution for sharing state between actions of different controllers?
Intro
There is a controller with its special action:
The controller above is embedded by a number of other controllers.
Those controllers are embedded by our main controller.
Problem
The problem is the
GrandParent
controller will be allocated twice, meaningc.Parent1.GrandParent != c.Parent2.GrandParent
. The output of theGrandParent
'sBefore
will be:As a result, we cannot share a context between controllers of different levels of embedding.
Use-case
This is the problem I've faced trying to implement #39. There is
controllers/errors
controller that is responsible for rendering error pages. We embed it in our main controller and mount its actions to* /errors
:Now if we want to pass some value to the actions of that
Errors
controller it doesn't work:Because,
Context
ofControllers
andContext
ofErrors
are different instances. But they must be pointers to the same object.Expectations
A single allocation per object per request. Special (
Before
andAfter
) actions must be called just once:Parents
must have priority over theirChildren
.The text was updated successfully, but these errors were encountered: