Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best practices for integrating with Flow<T> #80

Closed
Gregory991 opened this issue Oct 18, 2022 · 1 comment
Closed

Best practices for integrating with Flow<T> #80

Gregory991 opened this issue Oct 18, 2022 · 1 comment

Comments

@Gregory991
Copy link

I'm not really sure the best way to achieve this. It could very well be ignorance on my part.

I have an Android room table i want to Flow on. Something like: Flow<Vehicle>
First i need to get the userVehicleId from the User Repository. That isn't a flow, it returns Result<Int, Unit>

The function i have atm looks like this:

suspend fun getUserVehicle(): Flow<Result<Vehicle, Unit>>{ 
   return userRepo.getUserVehicle()              // returns `Result<Int, Unit> `
        .andThen{ id ->
            Ok(vehicleDao.flowOnUserVehicle(id)) // returns Flow<Vehicle, Unit>
        }
}

This isn't valid and won't compile. Since I'm returning Result<Flow<Vehicle, Unit>

Thanks in advance!

@michaelbull
Copy link
Owner

Thanks for your report. We have an active discussion on extensions for kotlin's Flow type in #78. Feel free to add any ideas or problems you are facing in that thread.

Closing as duplicate.

@michaelbull michaelbull closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants