Skip to content

How to create an InstanceKeeper #58

Answered by arkivanov
manosbatsis asked this question in Q&A
Discussion options

You must be logged in to vote

It depends on how you use the InstanceKeeper. Typically it is used to survive configuration changes on Android, and yet use it in common code. So the answers are:

  1. On Android, it's better to create InstanceKeeper using a ViewModelStore from an Activity or a Fragment. So InstanceKeeper shouldn't be a singleton, it's supposed to be destroyed when the activity/fragment is finished.
  2. On other platforms, the InstanceKeeper should be usually scoped to a screen. You can create and pass InstanceKeeperDispatcher there.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@arkivanov
Comment options

@manosbatsis
Comment options

@arkivanov
Comment options

Answer selected by manosbatsis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants