Skip to content

Commit

Permalink
Update storage.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kmahmood74 authored Jan 16, 2024
1 parent 9dce7c7 commit a007296
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions javascript-reference/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ API:
### Manually triggering binding updates
Updates due to bindings to the storage are triggered only when you set a parameter on the storage directly.

For example,
For example, the following triggers the binding and updates all the fields that are bound to ensemble.storage.myData
```js
ensemble.storage.myData = {name: {first:'John', last: 'Doe'};
```
However, if you are manipulating the data that is not directly stored in the `ensemble.storage`, it won't trigger binding.
```js
ensemble.storage.myData = {name: {first:'John', last: 'Doe'}; //triggers the binding and updates all the fields that are bound to ensemble.storage.myData
//However, if you are manipulating the data that is not directly stored in the `ensemble.storage`, it won't trigger binding.
ensemble.storage.myData.name.first = 'Jane'; //will NOT trigger binding and the `nameField.text` will NOT be updated.
//To solve this issue, we set storage parameter back to itself to trigger the update
//after doing all the manipulations to myData, set it back to itself
```
To solve this issue, we set storage parameter back to itself to trigger the update. After doing all the manipulations to myData, set it back to itself
```js
ensemble.storage.myData = ensemble.storage.myData; //this will now update nameField.text and any other fields listening for this change
```

Expand Down

0 comments on commit a007296

Please sign in to comment.