Skip to content

Conversation

@Magirus
Copy link

@Magirus Magirus commented Feb 2, 2025

Removed NavHost for ListDetailPaneScaffold

Creating NavHost object every time user goes to a new interest object is expensive. We may do it with more effective way. Especially when there are only two possible composable choices that can be switched with the only if statement.

) { topicIUState, newsUIState ->
_topicUIState.update { topicIUState }
_newsUIState.update { newsUIState }
}.stateIn(viewModelScope)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combines for old topicIds will continue to run right now, since these won't be cancelled if the topic id changes.

viewModel: TopicViewModel = hiltViewModel(),
viewModel: TopicViewModel = hiltViewModel()
) {
viewModel.updateTopic(topicId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line feels the strangest with this usage, since we are reusing a single instance of the ViewModel scoped to the overall navigation entry with many different topicIds that we are swapping between.

One side-effect is that we can't display two different versions of the TopicScreen at the same time, which might be ideal to animate between two different selected topics.

@alexvanyo
Copy link
Contributor

Thank you for proposing this for consideration - #1835 removed the nested NavHost with a slightly different approach, so closing this PR

@alexvanyo alexvanyo closed this Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants