https://kotlinlang.org logo
Title
l

Laura de la rosa

08/30/2019, 3:16 PM
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

Marko Mitic

08/30/2019, 3:18 PM
bundles have a size limit, so it might randomly crash
l

Laura de la rosa

08/30/2019, 3:20 PM
what is the size limit?
m

Marko Mitic

08/30/2019, 3:21 PM
500KB but it's shared among all active transactions so it's hard to say in practice
✔️ 2
🎉 1
j

jw

08/30/2019, 3:21 PM
You don't need to persist the list. Just store it somewhere in memory that's common to both fragments.
l

Laura de la rosa

08/30/2019, 3:22 PM
@jw like a singleton class?
j

jw

08/30/2019, 3:23 PM
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
😀 1
😂 18
l

Laura de la rosa

08/30/2019, 3:24 PM
@jw thnak you so much
m

Marko Mitic

08/30/2019, 3:25 PM
@jw not a fan of view models?
j

jw

08/30/2019, 3:25 PM
no
l

Laura de la rosa

08/30/2019, 3:25 PM
why?
m

Marko Mitic

08/30/2019, 3:28 PM
View models in general or AndroidX implementation?
j

jw

08/30/2019, 3:28 PM
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.
👍 2
😂 1
m

Marko Mitic

08/30/2019, 3:28 PM
that answers it 🙂
We'll have to make our own KMP-friendly viewmodels, with blackjack and h*****s
😆 4
k

Kelvin Pere

08/30/2019, 6:13 PM
@jw sent a DM
c

Cody Engel

08/30/2019, 6:57 PM
Android JakePack brought to you by Square
:trollface: 1
😂 4
d

dave08

09/01/2019, 2:12 AM
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

Pablichjenkov

09/01/2019, 11:00 PM
Use SOLID instead of Android ViewModels and liveData