ursus
04/05/2024, 9:12 PMvalue class
es worth it in world of reactive apps? i.e Flow<X>
is the base of modern architectures.
Somehow I feel like such boxing would produce more garbage than it saves in regular functions.
Am I wrong?Youssef Shoaib [MOD]
04/05/2024, 10:35 PMFlow<X>
where X is a value class, it will be boxed. However, if X is some class that has value
class properties, those won't be, hence it might be very useful for thatursus
04/05/2024, 10:53 PMYoussef Shoaib [MOD]
04/05/2024, 11:02 PMursus
04/05/2024, 11:07 PMflowOfValue
.filter { .. }
.scan { .. }
.distinctUntilChanged()
ursus
04/05/2024, 11:13 PMUserId
a parameter to the graph (@BindsInstance
) so you can inject "your" userId, without querying the dbursus
04/05/2024, 11:38 PMlistOf(FooId("abc"))
is this boxed as well?Konstantin
04/06/2024, 10:35 AMfilter
it's passed as an argument in the box, so no new instantiation should happen, in scan
ultimately it depends on what happens inside `scan`;
2. I don't see why it shouldn't work in Dagger, you may have to add qualifier annotation to help dagger distinguish it from raw backing type (String
or Long
or whatever you are using);
3. Yes, it will be boxed in any generic (collections, arrays, kotlin function types) or nullable context.
You can check whether boxing happens via show kotlin bytecode
action in IntelijIDEA (or Android Studio), but that requires some knowledge of java bytecode.