It looks like MutableLiveData
differs from LiveData
only by making the setValue()
and postValue()
methods public, whereas in LiveData
they are protected.
What are some reasons to make a separate class for this change and not simply define those methods as public in the LiveData
itself?
Generally speaking, is such a form of inheritance (increasing the visibility of certain methods being the only change) a well-known practice and what are some scenarios where it may be useful (assuming we have access to all the code)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…