CommandBus: replace deprecated implementation.

Convert CommandBus from deprecated BroadcastChannel to a SharedFlow.
This commit is contained in:
Hugh Daschbach 2022-08-20 17:04:54 -07:00 committed by Ryan Harg
parent be8901390e
commit 1a038b2355
No known key found for this signature in database
GPG Key ID: 89106F3A84E6958C
2 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,6 @@ import androidx.appcompat.app.AppCompatDelegate
import audio.funkwhale.ffa.koin.authModule
import audio.funkwhale.ffa.koin.exoplayerModule
import audio.funkwhale.ffa.utils.AppContext
import audio.funkwhale.ffa.utils.Command
import audio.funkwhale.ffa.utils.FFACache
import audio.funkwhale.ffa.utils.Request
import com.preference.PowerPreference
@ -26,7 +25,6 @@ class FFA : Application() {
var defaultExceptionHandler: Thread.UncaughtExceptionHandler? = null
val commandBus: BroadcastChannel<Command> = BroadcastChannel(10)
val requestBus: BroadcastChannel<Request> = BroadcastChannel(10)
override fun onCreate() {

View File

@ -86,13 +86,15 @@ object EventBus {
}
object CommandBus {
private var _commands = MutableSharedFlow<Command>()
var commands = _commands.asSharedFlow()
fun send(command: Command) {
GlobalScope.launch(IO) {
FFA.get().commandBus.trySend(command).isSuccess
_commands.emit(command)
}
}
fun get() = FFA.get().commandBus.asFlow()
fun get() = commands
}
object RequestBus {