Skip to content

Instantly share code, notes, and snippets.

@danailalexiev
Created October 5, 2022 07:58
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 danailalexiev/502c11a02c7ba5935080f60da8b756d0 to your computer and use it in GitHub Desktop.
Save danailalexiev/502c11a02c7ba5935080f60da8b756d0 to your computer and use it in GitHub Desktop.
Kotlin Multiplatform JS Interop
interface JokeClient {
suspend fun getRandomJoke(category: JokeCategory? = null): Result<Joke>
suspend fun getJokeCategories(): Result<List<JokeCategory>>
suspend fun findJoke(query: String): Result<JokeSearchResult>
}
internal class JokeClientImpl (private val apiClient: ApiClient) :
JokeClient {
override suspend fun getRandomJoke(category: JokeCategory?): Result<Joke> =
apiClient.getRandomJoke(category)
override suspend fun getJokeCategories(): Result<List<JokeCategory>> =
apiClient.getJokeCategories()
override suspend fun findJoke(query: String): Result<JokeSearchResult> =
apiClient.findJoke(query)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment