Hello, I use Accompanist Pager but it looses the s...
# compose
n
Hello, I use Accompanist Pager but it looses the state of screens. I researched a bit and ran into this issue. And a related issue on IssueTracker is still empty. Did anybody here face a similar issue at all?
i
Are you saying that values you save with
rememberSaveable
aren't being saved?
c
Accompanist horizontal Pager is implemented using Lazy*. So whether you use Pager, or just put all of your items in a LazyRow or lazyColumn, you'd probably be better off bubbling up your state to a single place for the screen (like a ViewModel) and reading from there.
i
Note that even Lazy* saves things using
rememberSaveable
- you shouldn't be losing that state
n
Thanks for answers. Data itself comes from ViewModel and I collect observable as state. However, whenever I go back to the previous tab, list is reloading again
i
What does "list is reloading again" mean? The ViewModel certainly continues to exist no matter what page you are on, so any data it has loaded would already be there when you go back to that page. Can you show your code?
c
@Ian Lake sorry. I was thinking about the "state" being just like state of a checkbox or something in a todo list. In that case, I don't believe that'd be persisted.