kenkyee
10/13/2021, 7:13 PMMikolaj Leszczynski
10/13/2021, 8:24 PM@Parcelize
and with it you can alter the generated serializer by excluding parts of the state or completely overriding the parceler.
Here’s a great article explaining how to do that and more: https://bladecoder.medium.com/a-study-of-the-parcelize-feature-from-kotlin-android-extensions-59a5adcd5909kenkyee
10/13/2021, 10:17 PMMikolaj Leszczynski
10/14/2021, 7:39 AMkenkyee
10/14/2021, 10:34 AMdata class Person(
val info: PersonInfo
val items: PagedList<Item>? = null)
@Parcelize
data class PersonInfo(
val firstName: String,
val lastName: String,
val age: Int,
) : Parcelable
Mikolaj Leszczynski
10/15/2021, 11:32 AMParceler
to only save what you need, or worst case scenario you just have to implement the parcelable manually. Both approaches suck but it’s easier to achieve exactly what you need.
I wasn’t aware of problems using @IgnoredOnParcel
like this, it seems like a glaring omission! 🤔 Haven’t used @Parcelize
a lot myself, so I assumed it would just work.
PS We have work to do in this respect - currently we’re forcing you to use Parcelable
which, as you can see, comes with some inherent problems…
And it won’t work cross-platform which is why we need a better solution anyway.Oleksii Malovanyi
10/15/2021, 12:24 PMkenkyee
10/15/2021, 12:31 PMMikolaj Leszczynski
10/15/2021, 12:36 PMyou can’t just leave it in the DB e.g., with Compose. The list is part of your state.This doesn’t mean you can’t cache it in the DB and load it from there when you restore
Might be a good opportunity to use KSP to generate the parcelable’s parcelizer? This way you could also validate that people aren’t stuffing giant blobs into savedstate too.That’s like an entirely new parcelization library project… 😅
Oleksii Malovanyi
10/15/2021, 12:38 PMkenkyee
10/15/2021, 12:39 PMOleksii Malovanyi
10/15/2021, 12:39 PM