Subscribe

PHOTO EMBED

Wed Jun 21 2023 12:46:46 GMT+0000 (Coordinated Universal Time)

Saved by @AndraAbly #javascript

model.subscribe('loading', loading => ...);
model.subscribe('update', data => ...);
model.subscribe('error', err => ...);
model.subscribe((loading, data, err) => ...);
content_copyCOPY

In order to listen to changes of the data model, you can use the subscribe method. When the model state is updated, it will emit events on the status. These events can be: loading (update is in progress), update (new version is available), error (something went wrong, e.g.: failed synchornisation or conflict).