I created a library here: https://github.com/chanjungkim/ALiveData
This library is made because of MutableLiveData<ArrayList<T>>
. Many people who learns about LiveData complains or they are confused with this type when they need to manipulate(add, remove, etc) the MutableLiveData. That's because ArrayList is easy to manipulate and _arrayList.value!!.add(item)
or _arrayList.value!!.remove(0)
seems to notify. But they don't.
At the end, when we want to notify, we must assign a value like _arrayList.value!! = mList
. ArrayList and List both need to set the data like _arrayList.value!! = mArrayList
or _arrayList.value!! = mList
.
My question is List doesn't have add(), remove(), etc. On the other hand, ArrayList already has those functions and helps us manipulate the list much easier.
some people suggested like this
_list.value = list.value.toMutableList().doWhatever().toList()
So, what's the point of using List over ArrayList? Could you give me example with the explanation of using it?
>` could work with a hidden `MutableLiveData>`.
– Shark Jun 18 '21 at 15:08