Detect Changes in Annotations

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.willChange Fires whenever a user action performed via the UI (e.g. drawing) on an annotation occurs.
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.
instance.addEventListener("annotations.load", loadedAnnotations => {
instance.addEventListener("annotations.willChange", event => {
  if (event.reason === PSPDFKit.AnnotationsWillChangeReason.DRAW_START) {
    console.log("The user is drawing...");
instance.addEventListener("annotations.change", () => {
  console.log("Something in the annotations has changed.");
instance.addEventListener("annotations.create", createdAnnotations => {
instance.addEventListener("annotations.update", updatedAnnotations => {
instance.addEventListener("annotations.delete", deletedAnnotations => {