This file contains hidden or 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 class KittenDataSourceImpl : KittenDataSource { | |
| override fun load(limit: Int, offset: Int): Maybe<String> = | |
| maybeFromFunction { | |
| val url = URL(makeKittenEndpointUrl(limit = limit, offset = offset)) | |
| val connection = url.openConnection() as HttpURLConnection | |
| connection | |
| .inputStream | |
| .bufferedReader() | |
| .use(BufferedReader::readText) |
This file contains hidden or 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 actual fun KittenDataSource(): KittenDataSource = KittenDataSourceImpl() |
This file contains hidden or 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 class KittenDataSourceImpl : KittenDataSource { | |
| override fun load(limit: Int, offset: Int): Maybe<String> = | |
| maybe<String> { emitter -> | |
| val callback: (NSData?, NSURLResponse?, NSError?) -> Unit = | |
| { data: NSData?, _, error: NSError? -> | |
| if (data != null) { | |
| emitter.onSuccess(NSString.create(data, NSUTF8StringEncoding).toString()) | |
| } else { | |
| emitter.onComplete() | |
| } |
This file contains hidden or 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
| class DetailsFragment(output: (Output) -> Unit): Fragment() { | |
| sealed class Output { | |
| object CloseClicked : Output() | |
| } | |
| } |
This file contains hidden or 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 | |
| import kotlin.random.Random | |
| import kotlin.time.ExperimentalTime | |
| import kotlin.time.measureTime | |
| private const val count = 10000000 | |
| var counter = 0 |
This file contains hidden or 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 | |
| import kotlin.random.Random | |
| import kotlin.time.ExperimentalTime | |
| import kotlin.time.measureTime | |
| private const val count = 10000 | |
| @ExperimentalTime | |
| fun main() { |
This file contains hidden or 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
| typealias Reducer<State, Effect> = (State, Effect) -> State |
This file contains hidden or 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
| class KittenComponent { | |
| private val store = | |
| KittenStoreImpl( | |
| network = KittenStoreNetwork(dataSource = KittenDataSource()), | |
| parser = KittenStoreParser | |
| ) | |
| private var view: KittenView? = null | |
| private var startStopScope: DisposableScope? = null |
This file contains hidden or 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
| class KittenComponent { | |
| fun onViewCreated(view: KittenView) { | |
| } | |
| fun onStart() { | |
| } | |
| fun onStop() { | |
| } |
This file contains hidden or 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 fun Event.toIntent(): Intent = | |
| when (this) { | |
| is Event.RefreshTriggered -> Intent.Reload | |
| } |