Per the example below from the LiveData Android documentation, what would be the RxJava 2 equivalent?
We certainly can use a combination of publish()
, refcount()
and replay()
to achieve the core of the MutableLiveData observable behavior. That said, what would be the analogous counterpart of mCurrentName.setValue()
as it pertains to detecting a change and emitting the corresponding event?
public class NameViewModel extends ViewModel {
// Create a LiveData with a String
private MutableLiveData<String> mCurrentName;
public MutableLiveData<String> getCurrentName() {
if (mCurrentName == null) {
mCurrentName = new MutableLiveData<String>();
}
return mCurrentName;
}
// Rest of the ViewModel...
}