Detecting If Annotations Have Changed

In addition to controlling annotation changes via our create, update, and delete APIs, we also expose a number of events that can be used to intercept annotation changes that originate in the UI by clicks from the user or that are synced from the server.

Event Use Case
annotations.load Fires whenever annotations are loaded from the document.
annotations.change Fires whenever the current annotations change due to a user action (e.g. clicking the UI) or via the API.
annotations.create Fires whenever annotations are created.
annotations.update Fires whenever annotations are updated.
annotations.delete Fires whenever annotations are deleted.
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
instance.addEventListener("annotations.load", loadedAnnotations => {
  console.log(loadedAnnotations);
});
instance.addEventListener("annotations.change", () => {
  console.log("Something in the annotations has changed.");
});
instance.addEventListener("annotations.create", createdAnnotations => {
  console.log(createdAnnotations);
});
instance.addEventListener("annotations.update", updatedAnnotations => {
  console.log(updatedAnnotations);
});
instance.addEventListener("annotations.delete", deletedAnnotations => {
  console.log(deletedAnnotations);
});
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
instance.addEventListener("annotations.load", loadedAnnotations => {
  console.log(loadedAnnotations);
});
instance.addEventListener("annotations.change", function() {
  console.log("Something in the annotations has changed.");
});
instance.addEventListener("annotations.create", function(
  createdAnnotations
) {
  console.log(createdAnnotations);
});
instance.addEventListener("annotations.update", function(
  updatedAnnotations
) {
  console.log(updatedAnnotations);
});
instance.addEventListener("annotations.delete", function(
  deletedAnnotations
) {
  console.log(deletedAnnotations);
});