Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain presenter state during config change and when screen isn't on top of backstack #306

Closed
kierse opened this issue Nov 29, 2022 · 1 comment
Labels
discussion Open discussions! enhancement New feature or request

Comments

@kierse
Copy link
Collaborator

kierse commented Nov 29, 2022

We need the ability to retain simple internal presenter state when a screen leaves the composition but remains on the backstack.

Clarification

When speaking of a presenter, there are 2 types of state:

  1. internal presenter state that drives its emissions
  2. state emitted by the presenter and consumed by the UI

In this case I am only concerned about the first type.

Reasoning

Right now, the internal presenter state is a combination of things:

  1. the Screen object
  2. internal state accumulated through user interactions (ie. events)
  3. data obtained and/or calculated using data from the screen and or events

When returning to the composition (due to Navigator.pop), a presenter can refetch/recalculate the state described in option 3 so it can be safely ignored here. Similarly, we already retain screen instances on the backstack ensuring any data they contain will always be available to its presenter.

The missing piece is the internal state described in option 2: state that builds up in response to a user interacting with a circuit. This state is transitive and is not something you'd typically want or need to persist somewhere more permanent (like a db).

What's missing is a mechanism allowing the presenter to retain this internal state. This missing functionality can lead to usability issues:

Example

A user is interacting with a list of data. They apply some filtering, make a selection, and navigate away. Later the user returns to the list screen by popping the navigator

Expected behaviour
The list should render using the previously applied filters

Current behaviour
The previous state was lost so the list renders without any filters.

Related bugs

This issue appears in the following bug report: #116

@kierse kierse added enhancement New feature or request discussion Open discussions! labels Nov 29, 2022
@kierse
Copy link
Collaborator Author

kierse commented Nov 29, 2022

Closing. I was mistaken in thinking that this functionality wasn't achievable using rememberSaveable but it is

@kierse kierse closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Open discussions! enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant