Closed JustJerem closed 3 years ago
This is actually a great workaround. I like it because it will allow us to ditch all the assisted injection and simplify the whole codebase.
Thanks @JustJerem ! I will open a PR with these changes shortly and tag you there.
@JustJerem I have created the PR here. Let me know if it's fine so I can merge it and close this issue.
You can remove the AssistedFactory for the viewmodel. Example :
EntryPointActivity.kt
FoodCategoryDetailsViewModel.kt
So you can delete :
And so, you can delete ViewModelAssistedFactory.kt and transform your activity for :
See official docs : https://developer.android.com/guide/navigation/navigation-programmatic#returning_a_result
I know that in this case, we use the information to bring the information back to a previous view, but since we have access to the backstack, we can also do that method here.
I saw it originally in a repo from Mitch Tabian. https://github.com/mitchtabian/Food2Fork-KMM/blob/6ab855181c76cab8ace282513efce2714b2a0b98/androidFood2Fork/src/main/java/com/codingwithmitch/food2forkkmm/android/presentation/recipe_detail/RecipeDetailViewModel.kt#L35
I can't create branch to make PR.