diff --git a/src/lib/AnnotationList.js b/src/lib/AnnotationList.js index 2744d6e9ccf1d3de0d4fa28647d85ac2631226a6..701ac5695923c444164e3c3f59fe4c58b7a9062c 100644 --- a/src/lib/AnnotationList.js +++ b/src/lib/AnnotationList.js @@ -21,8 +21,11 @@ export default class AnnotationList { /** */ get resources() { - if (!this.json || !this.json.resources) return []; + this._resources = this._resources || (() => { // eslint-disable-line no-underscore-dangle + if (!this.json || !this.json.resources) return []; - return flatten([this.json.resources]).map(resource => new AnnotationResource(resource)); + return flatten([this.json.resources]).map(resource => new AnnotationResource(resource)); + })(); + return this._resources; // eslint-disable-line no-underscore-dangle } } diff --git a/src/lib/AnnotationPage.js b/src/lib/AnnotationPage.js index 6eb0d9285f4e7acd147cf067c0a9350282d9c638..d83ac072d06d8417bfe05d2364f22ff852d43a2f 100644 --- a/src/lib/AnnotationPage.js +++ b/src/lib/AnnotationPage.js @@ -24,9 +24,12 @@ export default class AnnotationPage { /** */ get items() { - if (!this.json || !this.json.items) return []; + this._items = this._items || (() => { // eslint-disable-line no-underscore-dangle + if (!this.json || !this.json.items) return []; - return flatten([this.json.items]).map(resource => new AnnotationItem(resource)); + return flatten([this.json.items]).map(resource => new AnnotationItem(resource)); + })(); + return this._items; // eslint-disable-line no-underscore-dangle } /**