Commit 5445ad58 authored by Robert Knight's avatar Robert Knight

Improve comments for `load` method in `loadAnnotationsService`

It is safe to call `load` while annotations are already being loaded,
in that it does all the necessary cleanup/interruption of the existing
fetch. However it wasn't immediately clear to me from the code that this
was the case.
parent 1d00a99b
......@@ -35,7 +35,10 @@ export default function loadAnnotationsService(
let searchClient = null;
/**
* Load annotations
* Load annotations from Hypothesis.
*
* The existing set of loaded annotations is cleared before the new set
* is fetched. If an existing annotation fetch is in progress it is canceled.
*
* @param {LoadAnnotationOptions} options
*/
......@@ -44,6 +47,10 @@ export default function loadAnnotationsService(
store.removeAnnotations(store.savedAnnotations());
// Cancel previously running search client.
//
// This will emit the "end" event for the existing client and trigger cleanup
// associated with that client (eg. resetting the count of in-flight
// annotation fetches).
if (searchClient) {
searchClient.cancel();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment