Skip to content

Instantly share code, notes, and snippets.

@lukaszkalnik
Last active February 10, 2020 20:27
Show Gist options
  • Save lukaszkalnik/78febf9c533507544272a91f974b56b3 to your computer and use it in GitHub Desktop.
Save lukaszkalnik/78febf9c533507544272a91f974b56b3 to your computer and use it in GitHub Desktop.
package net.grandcentrix.gatewayapi.domain.usecase
internal typealias GetLightsUseCase = suspend (String) -> Either<Throwable, List<Light>>
internal typealias EntityConverter<T> = (Entity) -> T
internal fun getLightsUseCaseFactory(
api: GatewayApi,
converter: EntityConverter<List<Light>>
): GetLightsUseCase = { roomId: String ->
api.getLights(roomId)
.toEither()
.map { converter(it) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment