diff options
author | Allan Wang <me@allanwang.ca> | 2021-11-23 12:02:11 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2021-11-23 12:02:11 -0800 |
commit | 602290c33ac25f9308f8adfc459033cd50e13497 (patch) | |
tree | 423516151e716c035f729f49d03026a65af407c4 /app/src/main/kotlin/com/pitchedapps/frost/kotlin/CoroutineUtils.kt | |
parent | e8d9dca1ede1295f67e27faf731a5caa1bd2810a (diff) | |
download | frost-602290c33ac25f9308f8adfc459033cd50e13497.tar.gz frost-602290c33ac25f9308f8adfc459033cd50e13497.tar.bz2 frost-602290c33ac25f9308f8adfc459033cd50e13497.zip |
Remove broadcast channel and flyweight
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/kotlin/CoroutineUtils.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/kotlin/CoroutineUtils.kt | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/kotlin/CoroutineUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/kotlin/CoroutineUtils.kt deleted file mode 100644 index 6f8a60a9..00000000 --- a/app/src/main/kotlin/com/pitchedapps/frost/kotlin/CoroutineUtils.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2019 Allan Wang - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package com.pitchedapps.frost.kotlin - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.Job -import kotlinx.coroutines.channels.BroadcastChannel -import kotlinx.coroutines.launch -import kotlin.coroutines.CoroutineContext - -@UseExperimental(ExperimentalCoroutinesApi::class) -fun <T> BroadcastChannel<T>.subscribeDuringJob( - scope: CoroutineScope, - context: CoroutineContext, - onReceive: suspend (T) -> Unit -) { - val receiver = openSubscription() - scope.launch(context) { - for (r in receiver) { - onReceive(r) - } - } - scope.coroutineContext[Job]!!.invokeOnCompletion { receiver.cancel() } -} |