Created
March 5, 2022 23:45
-
-
Save gpeal/cfdf5a55c4bc3de8b32c29a156a79385 to your computer and use it in GitHub Desktop.
Anvil Simple Use Case
This file contains 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
@Singleton | |
class LocationProvider @Inject constructor() { | |
suspend fun currentLocation(): Pair<Float, Float> = 123.456f to 789.012f | |
} | |
class WeatherApi @Inject constructor() { | |
suspend fun getWeather(latLng: Pair<Float, Float>): Float = 72f | |
} | |
class WeatherUseCase @Inject constructor( | |
private val locationProvider: LocationProvider, | |
private val weatherApi: WeatherApi, | |
) { | |
suspend fun getWeather(): Float { | |
val location = locationProvider.currentLocation() | |
return weatherApi.getWeather(location) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment