Is there a "composable" way of sharing data betwee...
# compose
b
Is there a "composable" way of sharing data between screens like how you could use a shared view model for sharing data between fragments?
1
a
Sure:
Copy code
val sharedState = memo { createStateObject() }

when (screen) {
  Screen.First -> FirstScreen(sharedState)
  Screen.Second -> SecondScreen(sharedState)
}
👍 2
b
awesome, thanks! (:
a
Note that the above won't persist across config changes (yet) - stay tuned on that front. 🙂 what API you'll need to use in place of
memo
there may change but the idea will remain
👍 2