Better event-dispatcher with liteners that die with scope

This commit is contained in:
lucas lelievre committed 2026-07-23 22:04:49 +02:00
1 parent 8e19542c82
commit 05fbf64ac3
35 files changed
+174 -174

No files matched your search

@@ -10,6 +10,7 @@ import dev.slimevr.buildTestUserConfig
import dev.slimevr.buildTestVrServer
import dev.slimevr.context.Context
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runTest
import solarxr_protocol.MessageBundle
@@ -46,7 +47,7 @@ private fun testConn(backgroundScope: kotlinx.coroutines.CoroutineScope, onSend:
rpcDispatcher = EventDispatcher(),
)
bridge.startObserving()
bridge.outbound.on<MessageBundle> { _ -> onSend(ByteArray(0)) }
bridge.outbound.on<MessageBundle> { onSend(ByteArray(0)) }.launchIn(backgroundScope)
return bridge
}