mxCallbackFlow already contains a tryOrNull wrapper around the block, so not need to add an extra one.
Also the block can return a non-null TaskHandle.
This commit is contained in:
parent
750f07547c
commit
4a1aafae43
3 changed files with 8 additions and 15 deletions
|
|
@ -97,9 +97,7 @@ internal fun RoomListServiceInterface.stateFlow(): Flow<RoomListServiceState> =
|
||||||
trySendBlocking(state)
|
trySendBlocking(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tryOrNull {
|
state(listener)
|
||||||
state(listener)
|
|
||||||
}
|
|
||||||
}.buffer(Channel.UNLIMITED)
|
}.buffer(Channel.UNLIMITED)
|
||||||
|
|
||||||
internal fun RoomListServiceInterface.syncIndicator(): Flow<RoomListServiceSyncIndicator> =
|
internal fun RoomListServiceInterface.syncIndicator(): Flow<RoomListServiceSyncIndicator> =
|
||||||
|
|
@ -109,13 +107,11 @@ internal fun RoomListServiceInterface.syncIndicator(): Flow<RoomListServiceSyncI
|
||||||
trySendBlocking(syncIndicator)
|
trySendBlocking(syncIndicator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tryOrNull {
|
syncIndicator(
|
||||||
syncIndicator(
|
SYNC_INDICATOR_DELAY_BEFORE_SHOWING,
|
||||||
SYNC_INDICATOR_DELAY_BEFORE_SHOWING,
|
SYNC_INDICATOR_DELAY_BEFORE_HIDING,
|
||||||
SYNC_INDICATOR_DELAY_BEFORE_HIDING,
|
listener,
|
||||||
listener,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}.buffer(Channel.UNLIMITED)
|
}.buffer(Channel.UNLIMITED)
|
||||||
|
|
||||||
internal fun RoomListServiceInterface.roomOrNull(roomId: String): RoomListItem? {
|
internal fun RoomListServiceInterface.roomOrNull(roomId: String): RoomListItem? {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
package io.element.android.libraries.matrix.impl.sync
|
package io.element.android.libraries.matrix.impl.sync
|
||||||
|
|
||||||
import io.element.android.libraries.core.data.tryOrNull
|
|
||||||
import io.element.android.libraries.matrix.impl.util.mxCallbackFlow
|
import io.element.android.libraries.matrix.impl.util.mxCallbackFlow
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.coroutines.channels.trySendBlocking
|
import kotlinx.coroutines.channels.trySendBlocking
|
||||||
|
|
@ -24,7 +23,5 @@ fun SyncServiceInterface.stateFlow(): Flow<SyncServiceState> =
|
||||||
trySendBlocking(state)
|
trySendBlocking(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tryOrNull {
|
state(listener)
|
||||||
state(listener)
|
|
||||||
}
|
|
||||||
}.buffer(Channel.UNLIMITED)
|
}.buffer(Channel.UNLIMITED)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import kotlinx.coroutines.channels.awaitClose
|
||||||
import kotlinx.coroutines.flow.callbackFlow
|
import kotlinx.coroutines.flow.callbackFlow
|
||||||
import org.matrix.rustcomponents.sdk.TaskHandle
|
import org.matrix.rustcomponents.sdk.TaskHandle
|
||||||
|
|
||||||
internal fun <T> mxCallbackFlow(block: suspend ProducerScope<T>.() -> TaskHandle?) =
|
internal fun <T> mxCallbackFlow(block: suspend ProducerScope<T>.() -> TaskHandle) =
|
||||||
callbackFlow {
|
callbackFlow {
|
||||||
val taskHandle: TaskHandle? = tryOrNull {
|
val taskHandle: TaskHandle? = tryOrNull {
|
||||||
block(this)
|
block(this)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue