From ff6abef01ab63c51c3857d4f44fb4a0202ba1fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Fri, 19 Jul 2024 14:25:26 +0200 Subject: [PATCH] fix: always launch coroutines in IO (#50) * Change build in main job * Refresh toggles and send metrics on IO scope --- .github/workflows/build.yaml | 2 +- .../src/main/java/io/getunleash/android/DefaultUnleash.kt | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 62dc1ff..09592cf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Build +name: Build main on: push: diff --git a/unleashandroidsdk/src/main/java/io/getunleash/android/DefaultUnleash.kt b/unleashandroidsdk/src/main/java/io/getunleash/android/DefaultUnleash.kt index 9b8ccd2..56d3eb5 100644 --- a/unleashandroidsdk/src/main/java/io/getunleash/android/DefaultUnleash.kt +++ b/unleashandroidsdk/src/main/java/io/getunleash/android/DefaultUnleash.kt @@ -210,7 +210,9 @@ class DefaultUnleash( override fun refreshTogglesNow() { runBlocking { - fetcher?.refreshToggles() + withContext(Dispatchers.IO) { + fetcher?.refreshToggles() + } } } @@ -225,7 +227,9 @@ class DefaultUnleash( override fun sendMetricsNow() { if (!unleashConfig.metricsStrategy.enabled) return runBlocking { - metrics.sendMetrics() + withContext(Dispatchers.IO) { + metrics.sendMetrics() + } } }