refactor(deps): inject CoroutineDispatchers (#4170)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-01-08 17:40:26 -06:00 committed by GitHub
parent 68185460fa
commit 7744a42e1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 102 additions and 89 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* 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
@ -14,16 +14,20 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.network
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.meshtastic.core.di.CoroutineDispatchers
import org.meshtastic.core.model.NetworkDeviceHardware
import org.meshtastic.core.network.service.ApiService
import javax.inject.Inject
class DeviceHardwareRemoteDataSource @Inject constructor(private val apiService: ApiService) {
class DeviceHardwareRemoteDataSource
@Inject
constructor(
private val apiService: ApiService,
private val dispatchers: CoroutineDispatchers,
) {
suspend fun getAllDeviceHardware(): List<NetworkDeviceHardware> =
withContext(Dispatchers.IO) { apiService.getDeviceHardware() }
withContext(dispatchers.io) { apiService.getDeviceHardware() }
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* 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
@ -14,16 +14,20 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.network
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.meshtastic.core.di.CoroutineDispatchers
import org.meshtastic.core.model.NetworkFirmwareReleases
import org.meshtastic.core.network.service.ApiService
import javax.inject.Inject
class FirmwareReleaseRemoteDataSource @Inject constructor(private val apiService: ApiService) {
class FirmwareReleaseRemoteDataSource
@Inject
constructor(
private val apiService: ApiService,
private val dispatchers: CoroutineDispatchers,
) {
suspend fun getFirmwareReleases(): NetworkFirmwareReleases =
withContext(Dispatchers.IO) { apiService.getFirmwareReleases() }
withContext(dispatchers.io) { apiService.getFirmwareReleases() }
}