I've got a simple implementation of RXJava where when the app is loaded, the entire database is loaded:
Disposable ds = viewModel.geAllUsers()
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(modelClasses ->
{
Toast.makeText(this, "RoomWithRx: " + modelClasses.size(), Toast.LENGTH_LONG).show();
}, e -> Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show()
);
The issue is when I add a user:
Disposable subscribe1 = viewModel.addData2(new User(4, "ok", "test"))
.subscribe(
newUserID-> { },
throwable -> { }
);
Since I subscriped to the user table, each change triggers the subscriber and the entire database is loaded again. How can define a way where once the database is loaded in the beginning, only the changed Users should be loaded? There is no noChange()
method unfortunately.
question from:
https://stackoverflow.com/questions/66053546/room-rxjava-load-db-and-only-react-to-changes-after 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…