This commit is contained in:
Ilya Kantor 2019-08-13 13:42:36 +03:00
parent b9e6e757bb
commit 763aba5075
5 changed files with 243 additions and 95 deletions

View file

@ -20,8 +20,8 @@ user.observe((key, value) => {
user.name = "John"; // alerts: SET name=John
```
In other words, an object returned by `makeObservable` has the method `observe(handler)` that allows to add `handler` function to be called on a property change.
In other words, an object returned by `makeObservable` is just like the original one, but also has the method `observe(handler)` that sets `handler` function to be called on any property change.
Whenever a property changes, `handler(key, value)` is called with the name and value o the property.
Whenever a property changes, `handler(key, value)` is called with the name and value of the property.
P.S. In this task, please handle only writing to a property. Other operations can be implemented in a similar way.
P.S. In this task, please only take care about writing to a property. Other operations can be implemented in a similar way.