CommandBus: replace deprecated implementation.
Convert CommandBus from deprecated BroadcastChannel to a SharedFlow.
This commit is contained in:
parent
be8901390e
commit
1a038b2355
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue