How optimal is to pass a parcelable list of 1000 r...
# android
l
How optimal is to pass a parcelable list of 1000 rows or more from one fragment to another through a bundle? knowing that I can't persist that list and using navigation jetpack
m
bundles have a size limit, so it might randomly crash
l
what is the size limit?
m
500KB but it's shared among all active transactions so it's hard to say in practice
โœ”๏ธ 2
๐ŸŽ‰ 1
j
You don't need to persist the list. Just store it somewhere in memory that's common to both fragments.
l
@jw like a singleton class?
j
Well presumably both fragments are being displayed in the same activity, so you could use an object which is scoped to the activity instance
โค๏ธ 1
I shudder to even suggest this, but something like a view model in the activity will do just fine
๐Ÿ˜‚ 18
๐Ÿ˜€ 1
l
@jw thnak you so much
m
@jw not a fan of view models?
j
no
l
why?
m
View models in general or AndroidX implementation?
j
they're not view models in the defined sense, they have forced subclassing, they have unnecessary lifecycle, they're trying to steal the non-config instance support from activity. it's just a class-keyed service locator and factory with too many responsibilities that leads to bad architecture (no IoC) and state soup.
๐Ÿ˜‚ 1
๐Ÿ‘ 2
m
that answers it ๐Ÿ™‚
We'll have to make our own KMP-friendly viewmodels, with blackjack and h*****s
๐Ÿ˜† 4
k
@jw sent a DM
c
Android JakePack brought to you by Square
๐Ÿ˜‚ 4
๐ŸงŒ 1
d
Could you please link an example of what you use instead @jw? Or it's just a simple class with a CoroutineScope? Does yours live through the lifetime of the app, or is it limited by some way (there could be lots of them if they do manage state... but then, they shouldn't?).
p
Use SOLID instead of Android ViewModels and liveData