square / mortar

A simple library that makes it easy to pair thin views with dedicated controllers, isolated from most of the vagaries of the Activity life cycle.
Apache License 2.0
2.16k stars 156 forks source link

Missing Scope unregistering... :/ #164

Open Lakedaemon opened 9 years ago

Lakedaemon commented 9 years ago

I looked a bit at the MortarScope code and I'm a bit surprised that scopes can be started at any time after the start of a mortarScope but can only end when the mortarscope is destroyed and not sooner... Also services start with the mortarScope and end with it, so they can't be stopped or replaced in the same mortarScope

Why is that ? Is there something I don't see ?

Say, your want to store user settings and the user changes them, so you may have : |-- settings : ONE ---| |------ settings : TWO ----| |------------------- settings:THREE----|

Sure, you can store a user settings holder that takes care of this sub-scoping but wouldn't it be simpler to allow getting a scope and to tear it down from the mortarScope while it is not destroyed ?

Because they can be destroyed, to achieve this, it might be possible too to create a child MortarScope with the name "settings" holding Setting:ONE as a service ... and then destroying it ... and creating another child mortarScope with the same name.....

But it's not simple too

Also, the scoped services that the root mortar scope holds can't be stopped/ replaced before the end of the process.... :/

Am I missing something ?