When adding a binding allow "transaction" as scope.
Users can then create a "transaction" with:
kernel.beginTransaction("inteface");
And finish it with:
kernel.endTransaction("inteface");
Between beginTransaction and endTransaction if resolve is invoked:
kernel.resolve<inteface>("inteface");
The IoC container will use singleton scope.
If resolve is invoked before beginTransaction has been invoked the IoC container will use transient scope.
This is useful when we want a module to be a singleton within a scope. If we are in a scope (e.g.controller) and we navigate to a different scope (e.g. another controller) we might want our module to stop using singleton scope or create a new singleton within the new scope. All we need to do is to invoke beginTransaction when creating a scope (e.g. navigating to a controller) and endTransaction when leaving the scope (e.g. disposing the controller).
When adding a binding allow "transaction" as scope.
Users can then create a "transaction" with:
And finish it with:
Between
beginTransaction
andendTransaction
ifresolve
is invoked:The IoC container will use
singleton scope
.If
resolve
is invoked beforebeginTransaction
has been invoked the IoC container will usetransient scope
.This is useful when we want a module to be a
singleton
within ascope
. If we are in ascope
(e.g.controller
) and we navigate to a differentscope
(e.g. anothercontroller
) we might want our module to stop usingsingleton scope
or create anew singleton
within the newscope
. All we need to do is to invokebeginTransaction
when creating a scope (e.g. navigating to a controller) andendTransaction
when leaving the scope (e.g. disposing the controller).