Emiliano Schiavone
10/13/2021, 11:58 AMOrhan Tozan
10/13/2021, 12:57 PMMarko Novakovic
10/13/2021, 1:25 PMdata class
and sealed class
are totally different. data class
is product type and sealed class
is sum type all that means is that you have different number of cases to handlePair<Boolean, Boolean>
. this is 4 cases to handle. 2 * 2, 2 for first Boolean
(true and false) and 2 for second Boolean
data class
that has 5 parameters and every parameter had different parameters. it can get out of hand pretty quicklydata class
makes you handle more casesEmiliano Schiavone
10/13/2021, 1:30 PMMarko Novakovic
10/13/2021, 1:30 PMsealed class
on the other hand has a lot less, potentially, cases to handlesealed class
to model my statesEmiliano Schiavone
10/13/2021, 1:31 PMMarko Novakovic
10/13/2021, 1:33 PMsealed class
with Loading
, Error
and Success
than you have only 3 states to handle. Success
probably has some data so you need to handle those too but it reduces the number of cases because it only has 1 for Error
and 1 for 1 Loading
Emiliano Schiavone
10/13/2021, 1:50 PMMarko Novakovic
10/13/2021, 3:21 PMOrhan Tozan
10/13/2021, 3:24 PMEmiliano Schiavone
10/13/2021, 3:59 PMOrhan Tozan
10/13/2021, 4:00 PMMarko Novakovic
10/13/2021, 4:03 PMRecyclerView
-> LazyList
part of the UI react just to Success
and on Error
you have other part of UI that reacts to it