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
showThreads = true | |
val clientIO = Schedulers.newParallel("client-io", 2) | |
val serverIO = Schedulers.newParallel("server-io", 2) | |
val serverMain = Schedulers.newParallel("server-main", 2) | |
fun ioFetchUserById(id: Int) = | |
Mono.defer { fetchUserById(id) } | |
.delayElement(Duration.of(400, MILLIS)) | |
.subscribeOn(serverIO) |
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 br.com.gabryel.playground.rx | |
import io.reactivex.Observable | |
import io.reactivex.rxkotlin.toObservable | |
import io.reactivex.rxkotlin.zipWith | |
import java.time.LocalTime | |
import java.util.concurrent.TimeUnit | |
import kotlin.math.pow | |
fun main() { |
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
// Inferência de Tipo | |
val clearlyAString = "" | |
fun thisFunctionClearlyReturnsANumber(first: Int, second: Int) = first + second | |
fun thisReturnsNumberOfCharactersOnString(possibleString: Any)?: Int { | |
if (possibleString !is String) { | |
return IllegalStateException() | |
// Agora o código sabe que possibleString é sem sombra de dúvida uma String |
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
class PersonalInfo(val phone: String?) | |
class Person(val personalInfo: PersonalInfo?) |
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
// It seems that a Delegate Class always forwards to the same instance that it was created with. | |
// But it opens a possible misunderstanding: If I declare the delegated instance in the constructor | |
// as a var, shouldn't it change behaviour when the var changes? Or shouldn't a delegated instance | |
// always be a val, so it can't be changed? I think I prefer the first, as it would give the user more choice. | |
// General Interface | |
interface Context { | |
fun print(printable: String) | |
} |