[ ](https://kotlinlang.org) [ v1.9.23
](https://github.com/JetBrains/kotlin/releases/tag/v1.9.23)

  * Solutions 
    * [ Multiplatform ](/lp/mobile/)
    * [ Server-side ](/lp/server-side/)
    * [ Data science ](/docs/data-science-overview.html)
    * [ Android ](/docs/android-overview.html)
  * [ Docs ](/docs/home.html)
  * [ Community ](/community/)
  * [ Teach ](/education/)
  * Play 
    * [ Playground ](https://play.kotlinlang.org/)
    * [ Examples ](https://play.kotlinlang.org/byExample)
    * [ Koans ](https://play.kotlinlang.org/koans)

[ â Docs ](/docs/home.html)

[ kotlin-stdlib ](../../index.html) / [ kotlin.properties ](../index.html) / [
Delegates ](index.html) / [ observable ](./observable.html)

#  observable

Common

JVM

JS

Native

1.0

` inline  fun  < T  > observable  (  
Â Â Â Â  initialValue  :  Â  T  ,  
Â Â Â Â  crossinline  onChange  :  Â  (  property  :  Â [ KProperty
](../../kotlin.reflect/-k-property/index.html) < *  > ,  Â  oldValue  :  Â  T
,  Â  newValue  :  Â  T  )  Â  -> Â  Unit  
)  :  [ ReadWriteProperty  ](../-read-write-property/index.html) < Any  ?  ,
Â  T  > `  
[ (source)
](https://github.com/JetBrains/kotlin/tree/0938b46726b9c6938df309098316ce741815bb55/libraries/stdlib/src/kotlin/properties/Delegates.kt#L31)

Returns a property delegate for a read/write property that calls a specified
callback function when changed.

    
    
    import kotlin.properties.Delegates
    
    import kotlin.test.*
    
    fun main(args: Array<String>) {
    //sampleStart
    var observed = false
    var max: Int by Delegates.observable(0) { property, oldValue, newValue ->
        observed = true
    }
    
    println(max) // 0
    println("observed is ${observed}") // false
    
    max = 10
    println(max) // 10
    println("observed is ${observed}") // true
    //sampleEnd
    }

###  Parameters

` initialValue ` \- the initial value of the property.

` onChange ` \- the callback which is called after the change of the property
is made. The value of the property has already been changed when this callback
is invoked.

Stay in touch:

[ ](https://github.com/JetBrains/kotlin "Kotlin on GitHub") [
](https://twitter.com/kotlin "Kotlin on Twitter") [
](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up "Kotlin Slack") [
](https://www.reddit.com/r/Kotlin/ "Kotlin on Reddit") [
](https://stackoverflow.com/questions/tagged/kotlin "Kotlin on Stack
Overflow") [ ](https://www.youtube.com/channel/UCP7uiEZIqci43m22KDl0sNw
"Kotlin on YouTube")

  * [ Contributing to Kotlin ](https://kotlinlang.org/docs/contribute.html "Contributing to Kotlin")
  * [ Releases ](https://kotlinlang.org/docs/releases.html "Releases")
  * [ Press Kit ](https://kotlinlang.org/assets/kotlin-media-kit.pdf "Press Kit")
  * [ Security ](https://kotlinlang.org/docs/security.html "Security")
  * [ Blog ](https://blog.jetbrains.com/kotlin/ "Blog")
  * [ Issue Tracker ](https://youtrack.jetbrains.com/issues/KT "Issue Tracker")
  * [ Brand assets ](https://resources.jetbrains.com/storage/products/kotlin/docs/kotlin_logos.zip "Brand assets")
  * [ Careers ](https://www.jetbrains.com/careers/jobs/?team=Kotlin "Careers")

[ ](https://jetbrains.com)

Supported and developed byÂ [ JetBrains ](https://www.jetbrains.com/) .

Kotlinâ¢ isÂ protected under the  [ KotlinÂ Foundation
](https://kotlinlang.org/foundation/kotlin-foundation.html)  
andÂ licensed under the  [ Apache 2Â license
](https://github.com/JetBrains/kotlin-web-site/blob/master/LICENSE) .