Loading Annotations / Comments
At the moment we have two different approaches to add and removed annotations to or from the annotation-stream. The annotation-stream is used in the live-annotator, post-annotator, timeline-viewer and in the CommentThread of each annotationItem
1. Approach:
- Load Annotations from API
- Keep them in an Array and display the annotations in the frontend
- If a new Annotation is submitted use the submit response and add it to the Array. (Front-End Update)
- If an Annotation is deleted check the response and remove the annotation from the Array by filtering. (Front-End Update)
2. Approach
- Load Annotations from API
- Use the Array to display them in the frontend
- If a new Annotation is submitted, dumb the old array and reload the annotations from the API. (Front-End Update)
- If an Annotation is deleted, dumb the old array and reload the annotations from the API. (Front-End Update)
Pros / Cons
- Approach
- PRO: Less API Calls. After the first API Call only submit or delete API calls are emitted.
- CON: If there is any Error in the Backend, which is not handled in the frontend, the backend and the frontend may have different data until the next reload.
- Apporach
- PRO: The frontend always displays the data from the backend
- CON: More API calls. All annotations are reloaded if anything changes.
Everything will change when we start using websockets.
@christian.hansen please check if everything is correct :)