https://kotlinlang.org logo
b

Bryan Lee

12/26/2019, 4:24 PM
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

Adam Powell

12/26/2019, 4:30 PM
Sure:
Copy code
val sharedState = memo { createStateObject() }

when (screen) {
  Screen.First -> FirstScreen(sharedState)
  Screen.Second -> SecondScreen(sharedState)
}
👍 2
b

Bryan Lee

12/26/2019, 4:31 PM
awesome, thanks! (:
a

Adam Powell

12/26/2019, 4:32 PM
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
2 Views