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

How to shadow parent services with nested scopes #189

Open zoopolitic opened 8 years ago

zoopolitic commented 8 years ago

You can also spawn your own shorter lived scopes to manage transient sessions, like the state of an object being built by a set of wizard screens. These nested scopes can shadow the services provided by higher level scopes.

How this can be achieved? E.g. I have activity scope that provides dagger component and I want to spawn nested subscope(to provide subcomponent) that should shadow activity's dagger component. I'm using flow and I need to spawn subscope for several screens so the views of this screens will get subcomponent with Context.getSystemService instead of activity's component.

If I use buildChild() on acivity's scope then subscope will be just child of this scope, but it not shadows parent scope. Thanks.