ragdroid / Dahaka

Demo project for Dagger 2
Apache License 2.0
207 stars 35 forks source link

Why do we need activity scope? #11

Open chaitanya-exp opened 6 years ago

chaitanya-exp commented 6 years ago

We need new presenter on every activity creation anyways. If it is to handle activity recreation then the associated component will also be recreated which in turns results in new presenter object.

ragdroid commented 6 years ago

@chaitanya-exp It is for demonstration purposes, In future there can be a few dependencies which will live during the scope of for example just HomeActivity, like HomeActivityRouter (which can manage navigation between various fragments within HomeActivity, same instance can be injected into all three fragments but for a different activity I would still create a new Router. There could be multiple such examples. Here's just to demonstrate how we can do this.

chaitanya-exp commented 6 years ago

Thanks for the clarification. All the dagger related repos seem to use activity, fragment scope in their examples without a suitable usecase.