Skip to content

Instantly share code, notes, and snippets.

@Urdzik
Created April 25, 2021 05:12
Show Gist options
  • Save Urdzik/337ee74d2759c44f0b234400dfc79229 to your computer and use it in GitHub Desktop.
Save Urdzik/337ee74d2759c44f0b234400dfc79229 to your computer and use it in GitHub Desktop.
Kotlin Delegated (View)
fun TextView.text(): ReadWriteProperty<Any, String> =
object : ReadWriteProperty<Any, String> {
override fun getValue(
thisRef: Any,
property: KProperty<*>
): String = text.toString()
override fun setValue(
thisRef: Any,
property: KProperty<*>, value: String
) {
text = value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment