Skip to content

Commit

Permalink
loadAnnotations and setAnnotations now both return a Promise that com…
Browse files Browse the repository at this point in the history
…pletes after rendering
  • Loading branch information
rsimon committed Dec 2, 2021
1 parent 3f4f502 commit e2d4e61
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ <h1>Homer: The Odyssey</h1>
relationVocabulary: [ 'isRelated', 'isPartOf', 'isSameAs ']
});

r.loadAnnotations('annotations.w3c.json');
r.loadAnnotations('annotations.w3c.json')
.then(() => console.log('loaded'));

r.on('selectAnnotation', function(a) {
console.log('selected', a);
Expand Down
3 changes: 2 additions & 1 deletion src/TextAnnotator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ export default class TextAnnotator extends Component {
this.relationsLayer.clear();

const clones = annotations.map(a => a.clone());
this.highlighter.init(clones).then(() =>

return this.highlighter.init(clones).then(() =>
this.relationsLayer.init(clones));
}

Expand Down
5 changes: 2 additions & 3 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ export class Recogito {

loadAnnotations = (url, requestArgs) => fetch(url, requestArgs)
.then(response => response.json()).then(annotations => {
this.setAnnotations(annotations);
return annotations;
return this.setAnnotations(annotations).then(() => annotations);
});

off = (event, callback) =>
Expand All @@ -146,7 +145,7 @@ export class Recogito {
setAnnotations = arg => {
const annotations = arg || [];
const webannotations = annotations.map(a => new WebAnnotation(a));
this._app.current.setAnnotations(webannotations);
return this._app.current.setAnnotations(webannotations);
}

setAuthInfo = authinfo =>
Expand Down

0 comments on commit e2d4e61

Please sign in to comment.