# dagger

Colton Idle

03/13/2020, 9:10 AM
I've read a lot that you can do the same thing that AAC ViewModels give you if you just use Dagger. So you don't need VMs! No one ever seems to give an example of how this works even though I would assume there's only really 1 technique to get it done? I feel like I understand the Activity lifecycle fairly well, but I don't understand how Dagger would know how to scope something like my MessagingActivity across config changes. To go even further, maybe your Activity is open in split screen, and then you have another app that shares into your app in the other split screen. Essentially giving you two messaging activities. At this point, I would assume that you would have two distinct Scopes from dagger since you have two distinct instances of your MessagingActivity. How would I tell dagger to scope to a single instance of an activity where it will also know to "stay alive" and "outlive" the activity during config change? That's the big benefit of a AAC VM and I don't know where to start.


03/13/2020, 12:01 PM
I will answer when I get to a computer. Activities let you store objects across config changes so the quick answer is you just do that with your Dagger component
🙏 1

Colton Idle

03/23/2020, 4:13 PM
Just bumping this @jw Been heads down on dagger the last week or so and a lot of dots are connecting. But I can't wrap my head around his whole scoping to an Activity thing.