I'm a bit confused on why the following code doesn't work:
MutableLiveData<String> mutableTest = new MutableLiveData<>();
MediatorLiveData<String> mediatorTest = new MediatorLiveData<>();
mediatorTest.addSource(mutableTest, test -> {
Timber.d(test);
});
mutableTest.setValue("bla!");
This code seems straightforward, however the debugger doesn't enter the callback and nothing is logged to the console...
Edit: shouldn't this work then?
MutableLiveData<String> mutableTest = new MutableLiveData<>();
MediatorLiveData<String> mediatorTest = new MediatorLiveData<>();
mediatorTest.observe(loginActivity, str -> Timber.d(str));
mediatorTest.addSource(mutableTest, str -> Timber.d(str));
mutableTest.setValue("bla!");
> field and whenever I add a new task to the list from my Activity/Fragment a MediatorLiveData object that observes the MutableLiveData object would persist this new Task to a RoomDatabase?
– Bohsen Sep 25 '17 at 11:09