Out of curiosity, has anyone ever tried to use <an...
# compose
s
Out of curiosity, has anyone ever tried to use anvil and still get the convenience that Hilt gives with hiltViewModel(), especially when inside a composable destination where you get it scoped to the NavBackStackEntry. I guess I could go with hilt directly, but I really like the syntax anvil allows and the fact that my modules can stay kapt-free, so I’m trying to figure out if I can avoid it before just going with hilt 😅
Hmm I remembered some people talking about whetstone before, this may be exactly what I am looking for in this case 🤔
Seems like it may be possible, with
injectedViewModel()
after having enabled the compose whetstone addon, and making sure to provide it with the correct NavBackStackEntry from compose navigation. Just like you’d do with hilt. Unless I did smth wrong it seemed to work just fine, retaining the ViewModel while the scoped route was still in the backstack, and clearing itself when going back and in again 👀