Repository navigation
Serialization Help #386
Replies: 1 comment
|
The requirement comes from restoring the navigation stack on Android. Voyager's default JVM For example: data class DeviceScreen(val deviceId: String) : Screen {
@Composable
override fun Content() {
val repository = LocalDeviceRepository.current
val model = rememberScreenModel {
DeviceScreenModel(deviceId, repository)
}
DeviceContent(model)
}
}Here Voyager's DetailsScreen example follows this pattern: an identifier belongs to the screen, while On JVM there is an exclusion mechanism, That is why moving dependencies into the composition/model boundary is usually easier to maintain than making the screen manage serialization hooks. The requirement is about the screen's saved object graph; your repository, BLE connection, database, and other runtime objects do not all have to become serializable. |
Uh oh!
There was an error while loading. Please reload this page.
Some general implementation and & architectural questions here.
Just started fooling around with this lib, as I've come to understand every class member must implement serializable per the documentation, while non serializable objects are to be injected in composable functions locally.
Can someone please explain to me the idea behind forcing everything to be serializable?
I feel this clutters and boilerplates lots of code. Every function now needs to declare all these new local params that were class members and could easily be reinitialized in init{} or relevant lifecycle methods. Wouldn't it be possible to do the same here? Why not have an annotation to not serialize chosen class members and have them initialized manually?
Thanks in advance!
All reactions