Created
August 16, 2022 14:09
-
-
Save hi-manshu/392e7246c55c1c5c0cc7d56082cc800f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyUseCase @Inject constructor() { | |
private val getUserFlow: Flow<Int> = flowOf<Int>(1, 2, 3, 4) | |
private val getUserSessionFlow: Flow<Int> = flowOf<Int>(5, 6, 7, 8) | |
operator fun invoke(): Flow<Unit> { | |
return getUserFlow.zip(getUserSessionFlow) { user, session -> | |
// Do transformation here | |
} | |
} | |
} | |
@HiltViewModel | |
class MyViewModel @Inject constructor(val myUseCase: MyUseCase) : ViewModel() { | |
fun init() { | |
viewModelScope.launch { | |
myUseCase().collectLatest { | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment