diff options
Diffstat (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt index e74c7c4..a5d5bd7 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt @@ -48,19 +48,14 @@ class UnitsController( private val unitsFlow = MutableStateFlow<List<UnitInformation>>(emptyList()) private val queryFlow = MutableStateFlow("") - private var unitsUpdateJob: Job? = null - init { GlobalScope.launch { - fetchUnits(this) - } - GlobalScope.launch { setupFlows() } } - private suspend fun fetchUnits(scope: CoroutineScope) { - unitsUpdateJob = Coroutines.tickerFlow(UPDATE_TIME.seconds) + fun fetchUnits(scope: CoroutineScope) { + Coroutines.tickerFlow(UPDATE_TIME.seconds) .map { print("Fetching new positions...\n") positionsApi.positionsGet() @@ -90,10 +85,6 @@ class UnitsController( .launchIn(scope) } - fun stopUpdates() { - unitsUpdateJob?.cancel() - } - fun search(query: String) { queryFlow.value = query } |