android / android/architecture-samples

Replace Navigation Action with popBackStack

Open
#811 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
45.8k
Forks
11.9k
PR merge metrics
No merged PRs in 30d

Description

Currently after creating a new Todo in `AddEditTaskFragment` the code uses a navigation component _action_ to get back to the `TasksFragment` and passing a message (Task added). This leads to current `TaskFragment` object and its `TasksViewModel` to be destroyed. It's not ideal since we are observing database for new todos and there's no need to start over the process of retrieving all the todos.

Instead the code can use **SavedStateHandle** for setting a message and popping the back stack to get back to `TasksFragment` which is listening to _backStackEntry_'s `LiveData` for any changes.

Contributor guide

Open the contributing guide

Research direction

Start in AddEditTaskFragment and TasksFragment, tracing the current navigation action and the TasksViewModel lifecycle. Review how SavedStateHandle and the backStackEntry LiveData are used for the message, then verify that creating a Todo returns to the existing TasksFragment without recreating its view model and still displays the “Task added” message.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.