Closed georgiscoolman closed 3 years ago
hello! thanks for feedback!
you can select you own type with support of nullability exactly for your use-case, so if you not want initial data - just create MutableLiveData<Int?>(initalValue = null)
.
we can't add empty constructor because class is generic with strong generic type (if we use LiveData<Int>
it 100% not have null in any time).
With a nullable, isn't null
an initial value that would be propagated through the livedata chain ?
null will be propagated. also if you just call liveData.value
you got null too. so with strong generic type we can't do MutableLiveData<Int>()
- we broke api in this case, because while you not set some value in storage will be null
value.
Thank you for nice mpp mvvm solution! It will be great if MutableLiveData will have empty constructor. It will let developer to handle case when there is no initial data. And then post updates when some process will be done.