aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/utils/KotlinUtils.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-11-23 18:29:05 -0800
committerGitHub <noreply@github.com>2021-11-23 18:29:05 -0800
commit120ad1520db9184ebfa00885066e06a9f976e5f6 (patch)
tree50835fa79cf15ff348be386c46cea0a05552ba74 /app/src/main/kotlin/com/pitchedapps/frost/utils/KotlinUtils.kt
parente246b35323e27dd18fa48910e5ca95669b53f8b0 (diff)
parentdb646e23ce0047461e68be1af7021ce6171ac850 (diff)
downloadfrost-120ad1520db9184ebfa00885066e06a9f976e5f6.tar.gz
frost-120ad1520db9184ebfa00885066e06a9f976e5f6.tar.bz2
frost-120ad1520db9184ebfa00885066e06a9f976e5f6.zip
Merge pull request #1857 from AllanWang/flows
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/KotlinUtils.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/KotlinUtils.kt36
1 files changed, 0 insertions, 36 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/KotlinUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/KotlinUtils.kt
deleted file mode 100644
index f4357c9b..00000000
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/KotlinUtils.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2018 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.utils
-
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.channels.ReceiveChannel
-import kotlinx.coroutines.channels.produce
-import kotlinx.coroutines.isActive
-
-@UseExperimental(ExperimentalCoroutinesApi::class)
-fun <T> ReceiveChannel<T>.uniqueOnly(scope: CoroutineScope): ReceiveChannel<T> = scope.produce {
- var previous: T? = null
- for (current in this@uniqueOnly) {
- if (!scope.isActive) {
- cancel()
- } else if (previous != current) {
- previous = current
- send(current)
- }
- }
-}