Skip to content

Commit 2438d15

Browse files
committed
replace try {} finally
1 parent fc3f0c7 commit 2438d15

File tree

1 file changed

+3
-8
lines changed
  • firebase-database/src/androidMain/kotlin/dev/teamhub/firebase/database

1 file changed

+3
-8
lines changed

firebase-database/src/androidMain/kotlin/dev/teamhub/firebase/database/database.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,10 @@ suspend fun <T> Task<T>.awaitWhileOnline(): T = coroutineScope {
2727
.filter { !it.value<Boolean>() }
2828
.produceIn(this)
2929

30-
try {
31-
select<T> {
32-
asDeferred().onAwait { it }
33-
notConnected.onReceive { throw DatabaseException("Database not connected") }
34-
}
35-
} finally {
36-
notConnected.cancel()
30+
select<T> {
31+
asDeferred().onAwait { it.also { notConnected.cancel() } }
32+
notConnected.onReceive { throw DatabaseException("Database not connected") }
3733
}
38-
3934
}
4035

4136
actual val Firebase.database

0 commit comments

Comments
 (0)