r/android_devs • u/Zhuinden EpicPandaForce @ SO • Jun 19 '20
Coding Simplifying Jetpack Navigation between top-level destinations using Dagger-Hilt
https://medium.com/@Zhuinden/simplifying-jetpack-navigation-between-top-level-destinations-using-dagger-hilt-3d918721d91e
14
Upvotes
3
u/Boza_s6 Jun 19 '20
I wrote on androiddev, but forgot you're banned. C/p
This the only sane thing to do. Emitting events for fragment, just because it has reference to navcontroller, to handle makes no sense.
I discussed this here https://www.reddit.com/r/android_devs/comments/gzsere/z/ftkysaz
Two problem with design you come up with:
It's not possible to save queued actions across process death
nothing guarantees that lambda you enqueued does not have reference to outer viewmodel. If you during recreation remove that viewmodel by removing fragment, you'll have short leak
Both are consequence of storing actions instead of some identifiers. You could say
myNavInterface.navigate(r.id.somescreen)and save id to queue with maybe some more data if necessary