I think the easiest way to explain is with a code example that includes RxJava
class SomeClass {
CompositeSubscriptions subscriptions;
public SomeClass(CompositeSubscription subscriptions) {
this.subscriptions = subscriptions;
subscriptions.add(...);
subscriptions.add(...);
subscriptions.add(...);
subscriptions.add(...);
subscriptions.add(...);
}
public void destory() {
subscriptions.unsubscribe();
}
}
So what I want to be able to do is to have classes just be able to ask for a CompositeSubscription and they get the one for there scope. That way they can freely unsubscribe the whole CompositeSubscription. This would be needed so that my Singletons don't interfere with my Activities which don't interfere with my Fragments.
You cannot have the same class provided in multiple scopes. You get an error
{Class} is bound multiple times
.So the following setup is not valid
So there are two solutions that I know of.
I seem to prefer the Subclass per scope because I feel like it is a bit safer when refactoring, but both should work.