|
|
|
@ -19,8 +19,6 @@ package com.google.samples.apps.nowinandroid.core.data
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
|
|
|
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
|
import kotlin.coroutines.cancellation.CancellationException
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -104,29 +102,3 @@ suspend fun Synchronizer.changeListSync(
|
|
|
|
|
versionUpdater(latestVersion)
|
|
|
|
|
}
|
|
|
|
|
}.isSuccess
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a [Flow] whose values are generated by [transform] function that process the most
|
|
|
|
|
* recently emitted values by each flow.
|
|
|
|
|
*/
|
|
|
|
|
fun <T1, T2, T3, T4, T5, T6, R> combine(
|
|
|
|
|
flow: Flow<T1>,
|
|
|
|
|
flow2: Flow<T2>,
|
|
|
|
|
flow3: Flow<T3>,
|
|
|
|
|
flow4: Flow<T4>,
|
|
|
|
|
flow5: Flow<T5>,
|
|
|
|
|
flow6: Flow<T6>,
|
|
|
|
|
transform: suspend (T1, T2, T3, T4, T5, T6) -> R,
|
|
|
|
|
): Flow<R> = combine(
|
|
|
|
|
combine(flow, flow2, flow3, ::Triple),
|
|
|
|
|
combine(flow4, flow5, flow6, ::Triple),
|
|
|
|
|
) { t1, t2 ->
|
|
|
|
|
transform(
|
|
|
|
|
t1.first,
|
|
|
|
|
t1.second,
|
|
|
|
|
t1.third,
|
|
|
|
|
t2.first,
|
|
|
|
|
t2.second,
|
|
|
|
|
t2.third,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|