tgoop.com/kotlin_broadcast/1856
Create:
Last Update:
Last Update:
Уже успели попробовать в продакшен проектах Kotlin Context Parameter? Появились в Kotlin 2.2.0 в экспериментальном режиме. Делитесь впечатлениями
// UserService defines the dependency required in the context
interface UserService {
fun log(message: String)
fun findUserById(id: Int): String
}
// Declares a function with a context parameter
context(users: UserService)
fun outputMessage(message: String) {
// Uses log from the context
users.log("Log: $message")
}
// Declares a property with a context parameter
context(users: UserService)
val firstUser: String
// Uses findUserById from the context
get() = users.findUserById(1)
BY Kotlin Multiplatform Broadcast
Share with your friend now:
tgoop.com/kotlin_broadcast/1856