Skip to content

Commit f22f6b7

Browse files
author
haohao
authored
Create README.md
1 parent 0d55e72 commit f22f6b7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,5 +989,31 @@ fun main(args: Array<String>) {
989989
// Hello Kotlin
990990
```
991991
---
992+
993+
### Kotlin observable 观察者
994+
995+
**Kotlin**
996+
```kotlin
997+
class Person{
998+
public var name: String by Delegates.observable("init .. "){
999+
property,oldValue,newValue -> println("property : $property, oldValue : $oldValue, newValue : $newValue")
1000+
}
1001+
}
1002+
1003+
fun main(args: Array<String>) {
1004+
val person = Person()
1005+
1006+
println(person.name)
1007+
1008+
person.name = "haohao"
1009+
person.name = "nannan"
1010+
}
1011+
1012+
//输出:
1013+
//   init ..
1014+
//   property : var Person.name: kotlin.String, oldValue : init .. , newValue : haohao
1015+
// property : var Person.name: kotlin.String, oldValue : haohao, newValue : nannan
1016+
```
1017+
---
9921018
### 持续更新中...
9931019

0 commit comments

Comments
 (0)