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
func getRandomJoke(jokeCategory: JokeCategory?, completionHandler: (Result<Joke>?, Error?) -> ()) { | |
... | |
} |
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
internal interface ApiClient { | |
suspend fun getRandomJoke(category: JokeCategory? = null): Result<Joke> | |
suspend fun getJokeCategories(): Result<List<JokeCategory>> | |
suspend fun findJoke(query: String): Result<JokeSearchResult> | |
} |
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
interface JokeClient { | |
suspend fun getRandomJoke(category: JokeCategory? = null): Result<Joke> | |
suspend fun getJokeCategories(): Result<List<JokeCategory>> | |
suspend fun findJoke(query: String): Result<JokeSearchResult> | |
} |
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
import Foundation | |
import sdk | |
extension JokeClient { | |
func getRandomJokeAsync(jokeCategory: JokeCategory? = nil) async throws -> Joke { | |
return try await convertToAsync(kotlinCall: { completionHandler in | |
self.getRandomJoke(category: jokeCategory, completionHandler: completionHandler) | |
}) | |
} |
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
import Foundation | |
import sdk | |
typealias NativeCompletionHandler<Result> = (Result?, Error?) -> () | |
typealias NativeCall<Result> = (@escaping NativeCompletionHandler<Result>) -> NativeCancellable | |
func convertToAsync<Result>(kotlinCall call: @escaping NativeCall<Result>) async throws -> Result { | |
let cancellableActor: NativeCancellableActor = NativeCancellableActor() | |
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
interface JokeClient { | |
fun getRandomJoke( | |
category: JokeCategory? = null, | |
completionHandler: CompletionHandler<Joke?> | |
): NativeCancellable | |
fun getJokeCategories(completionHandler: CompletionHandler<List<JokeCategory>?>): NativeCancellable | |
fun findJoke( |
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
package com.infinitelambda.chuck.util | |
import kotlinx.coroutines.* | |
import platform.Foundation.NSError | |
import platform.Foundation.NSLocalizedDescriptionKey | |
import kotlin.coroutines.CoroutineContext | |
import kotlin.coroutines.EmptyCoroutineContext | |
import kotlin.native.concurrent.SharedImmutable | |
import kotlin.native.concurrent.ThreadLocal | |
import kotlin.native.concurrent.freeze |
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
interface JokeClient { | |
suspend fun getRandomJoke(category: JokeCategory? = null): Result<Joke> | |
suspend fun getJokeCategories(): Result<List<JokeCategory>> | |
suspend fun findJoke(query: String): Result<JokeSearchResult> | |
} |
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
package com.infinitelambda.chuck.util | |
import io.ktor.client.plugins.logging.* | |
internal actual object HttpLogger : Logger { | |
override fun log(message: String) { | |
console.log("$TAG: $message") | |
} |
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
package com.infinitelambda.chuck.util | |
import io.ktor.client.plugins.logging.* | |
import platform.Foundation.NSLog | |
internal actual object HttpLogger: Logger { | |
override fun log(message: String) { | |
NSLog("$TAG: $message") | |
} |
NewerOlder