I'm using Jetpack Navigation and Hilt in my project and I want to share ViewModel between only two Fragments, like this:
- Fragment A: use ViewModel A
- In Fragment A navigate to Fragment B: use ViewModel B
- In Fragment B navigate to Fragment C: use instance of ViewModel B
- If from C back to B, back to A then ViewModel B will be destroyed.
How to config ViewModel B like that?
UPDATE: I found a way to use Hilt Custom Scope, but I don't know how to implement it yet.
Thanks in advance.