Sign in Go Pro


Delegation Using Delegates.observable




While writing programs, we often need to monitor changes made to the value of a variable. For this purpose, most of the time we implement custom setters and call a function from there, which can make a program quite complex.

Fortunately, Kotlin comes to our aid with the Delegates.observable delegate, which is, among the standard delegates in Kotlin.

In this lesson you will learn:

  • How the Delegates.observable delegation works
  • How to monitor a variable with Delegates.observable
  • How to use Delegates.observable with custom classes




it's not that hard to create it from scratch using functions or interfaces like the java style, I wonder why they are adding it to the kotlin core api..?

You need to go PRO to post comments.

Lessons in Kotlin