Skip to content

Commit

Permalink
replace deprecated channel method
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiwiegg authored and sugarmanz committed Nov 8, 2023
1 parent 3950c38 commit 26fbd13
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ internal fun AndroidPlayer.updates(flow: JsonElement, take: Int = 1) = updates(f
internal fun AndroidPlayer.updates(flow: String, take: Int = 1): Flow<Update> = callbackFlow {
var count = 0
onUpdate { asset, _ ->
offer(Update.Asset(asset, count))
trySend(Update.Asset(asset, count)).isSuccess
if (++count >= take) close()
}

hooks.state.tap { state ->
offer(Update.State(state ?: ErrorState.from("state was null")))
trySend(Update.State(state ?: ErrorState.from("state was null"))).isSuccess
}

start(flow).onComplete {
Expand Down

0 comments on commit 26fbd13

Please sign in to comment.