Vivek Modi
03/04/2022, 9:32 PMopen class Shape {
var data : List<Shape> = emptyList()
}
Three child class which are inherited through Shape class called Circle, Rectangle, Triangle.
I create a variable called
val shape = Shape()
Vivek Modi
03/04/2022, 9:32 PMfun calculateData(){
val list = comingFromServer()
list.forEach{ shape->
shape.circle?.let{
// adding data
}
shape.rectangle?.let{
// adding data
}
shape.triangle?.let{
// adding data
}
}
}
I have few points in which I want your suggestion and best approach.
I want to notify my view that my code is go inside the let of shape.circle?
and shape.rectangle?
or not . Also I want to notify my view that my code inside shape.triangle?
. My List is this type of type of coming from server
List(CircleData, RectangleData, TriangleData)
or
List(CircleDataNull, RectangleDataNull, TriangleData)
I want to know, how can I to notify my view in best approach. What would you suugest to use MutableLiveData, MutableStateFlow or MutableSharedFlow. Please give me example which one is best. ThanksTim Oltjenbruns
03/04/2022, 10:28 PMVivek Modi
03/05/2022, 12:53 AMList(CircleData, RectangleData, TriangleData)....... Upto unlimited
or Scenario 2
`List(nu`ll`, nu`ll`, TriangleData).... Upto unlimited`
My whole list would be scenario 1 or Scenario 2. But when Scenario 1 I need to notify my activity that I have all three view present in the list. And when Scenario 2 then I will notify the activity that I have only Triangle Data.Vivek Modi
03/05/2022, 1:00 AMTim Oltjenbruns
03/05/2022, 3:44 AMVivek Modi
03/05/2022, 7:57 PMTim Oltjenbruns
03/05/2022, 8:04 PMval squares = listOf(Square(), Triangle(), Triangle()).filterIsInstance<Square>()
this gets you just the squares in this list.Tim Oltjenbruns
03/05/2022, 8:04 PMVivek Modi
03/05/2022, 8:06 PM