Skip to content

Instantly share code, notes, and snippets.

@hi-manshu
Created August 16, 2022 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hi-manshu/392e7246c55c1c5c0cc7d56082cc800f to your computer and use it in GitHub Desktop.
Save hi-manshu/392e7246c55c1c5c0cc7d56082cc800f to your computer and use it in GitHub Desktop.
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