Mohammed Akram Hussain
06/22/2024, 11:50 AMdataStoreManager.getShopDomain().distinctUntilChanged().collectLatest { shop ->
dataStoreManager.getStorefrontAccessToken().distinctUntilChanged().collectLatest { accessToken ->
if (shop.isNotEmpty() && accessToken.isNotEmpty()) {
// Build the graph client
I need to collect from two flows and do something but having nested collectLatest
is making me think if it's the right approach? Is there a better way which does the same as above?stojan
06/22/2024, 12:03 PMcombine
on the two flowsMohammed Akram Hussain
06/22/2024, 12:36 PMcombine
is behaving differently than collectLatest
ephemient
06/22/2024, 12:39 PMcombine(f, g) { x, y -> x to y }.collectLatest { (x, y) ->
gildor
06/24/2024, 1:37 AMMohammed Akram Hussain
06/24/2024, 7:53 AMcombineLatest
has been deprecated for combine
gildor
06/24/2024, 9:01 AMfun <T1, T2, R> combineLatest(
flow: Flow<T1>,
flow2: Flow<T2>,
transform: suspend (T1, T2) -> R
): Flow<R> = combine(flow, flow2) { t1, t2 -> listOf(t1, t2) }
.mapLatest { args ->
@Suppress("UNCHECKED_CAST")
transform(
args[0] as T1,
args[1] as T2
)
}
Mohammed Akram Hussain
06/24/2024, 9:14 AM