我将适配器与room-db Flowables绑定
db.myDao().loadByTrackId(tracksId)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe({ comments ->
Timber.d("setDataAD " + comments.size())
adapter.setData(comments.toMutableList())
}, ...
)
我从某个地方更新了会议室数据库
db.myDao().updateComments(pair.first.data, pair.second.data)
dao:
@Transaction
fun updateComments(commentOrigin: List<Comment>, commentNew: List<Comment>) {
delete(commentOrigin)
insertAll(commentNew)
}
@Delete
fun delete(comments: List<Comment>)
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(comments: List<Comment>)
现在删除3个并插入3个并使用@Transaction的方法时,我假设一个事件与Flowable有关,但我测量了Flowables的烟火
setDataAD 0
setDataAD 3
setDataAD 3
setDataAD 0
setDataAD 0
setDataAD 3
setDataAD 0
setDataAD 0
setDataAD 3
setDataAD 0
setDataAD 3
setDataAD 0
setDataAD 0
setDataAD 3
setDataAD 3
setDataAD 0
setDataAD 0
setDataAD 3
setDataAD 0
setDataAD 3
setDataAD 0
setDataAD 0
setDataAD 3
setDataAD 0
setDataAD 3
setDataAD 3
如何解决这个问题,使其仅获得一个事件/ Flowable? 或换句话说:如何防止Flowables反映一些数据库更新