-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use json polymorphic serialization to serialize ScreenParams. remove …
…paramsAsString
- Loading branch information
Showing
10 changed files
with
108 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...d/src/commonMain/kotlin/eu/baroncelli/dkmpsample/shared/viewmodel/screens/ScreenParams.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package eu.baroncelli.dkmpsample.shared.viewmodel.screens | ||
|
||
|
||
import eu.baroncelli.dkmpsample.shared.viewmodel.screens.countrieslist.CountriesListType | ||
import kotlinx.serialization.Serializable | ||
|
||
/*** | ||
* [ScreenParams] is an interface which defines the parameters to the passed to the screen if any are needed. | ||
* Each class which implements it should be a data class and should always be set as [Serializable] | ||
* | ||
* Note: we are defining all implementations here instead of inside a screen's | ||
* eu.baroncelli.dkmpsample.shared.viewmodel.screens.`screen-name` subpackage, because all classes implementing | ||
* a sealed interface must be in the same package. The reason we are using a sealed interface is that it | ||
* allows the list of ScreenParams subclasses that can be serialized in a polymorphic way to be | ||
* determined at compile time vs having to explicitly registered them at runtime. | ||
* See: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#open-polymorphism | ||
*/ | ||
@Serializable | ||
sealed interface ScreenParams | ||
|
||
@Serializable | ||
data class CountriesListParams(val listType: CountriesListType) : ScreenParams | ||
|
||
@Serializable | ||
data class CountryDetailParams(val countryName: String) : ScreenParams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
...tlin/eu/baroncelli/dkmpsample/shared/viewmodel/screens/countrydetail/CountryDetailInit.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters