优化
This commit is contained in:
@@ -231,12 +231,12 @@ fun <T> Flow<T>.flowWithLifecycleAndDatabaseChangeFirst(
|
|||||||
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
|
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
|
||||||
table: String
|
table: String
|
||||||
): Flow<T> = callbackFlow {
|
): Flow<T> = callbackFlow {
|
||||||
|
val channel = appDb.invalidationTrackerFlow(table, emitInitialState = false)
|
||||||
|
.conflate()
|
||||||
|
.produceIn(this)
|
||||||
if (!lifecycle.currentState.isAtLeast(minActiveState)) {
|
if (!lifecycle.currentState.isAtLeast(minActiveState)) {
|
||||||
send(first())
|
send(first())
|
||||||
}
|
}
|
||||||
val channel = appDb.invalidationTrackerFlow(table)
|
|
||||||
.conflate()
|
|
||||||
.produceIn(this)
|
|
||||||
lifecycle.repeatOnLifecycle(minActiveState) {
|
lifecycle.repeatOnLifecycle(minActiveState) {
|
||||||
channel.receive()
|
channel.receive()
|
||||||
this@flowWithLifecycleAndDatabaseChangeFirst.collect {
|
this@flowWithLifecycleAndDatabaseChangeFirst.collect {
|
||||||
|
|||||||
Reference in New Issue
Block a user