diff --git a/packages/entity/index.js b/packages/entity/index.js index a437c1f..ac7b296 100644 --- a/packages/entity/index.js +++ b/packages/entity/index.js @@ -119,6 +119,7 @@ export class Entity extends decorate(Resource) { constructor(json, jsonext) { super(); this._hooks = {}; + this._hydrationPromise = undefined; this._json = Entity.jsonWithDefaults(json); this._traits = {}; this._traitsFlat = []; @@ -230,11 +231,14 @@ export class Entity extends decorate(Resource) { } hydrate() { - const promises = []; - for (let i = 0; i < this._traitsFlat.length; i++) { - promises.push(this._traitsFlat[i].hydrate()); + if (!this._hydrationPromise) { + const promises = []; + for (let i = 0; i < this._traitsFlat.length; i++) { + promises.push(this._traitsFlat[i].hydrate()); + } + this._hydrationPromise = Promise.all(promises); } - return Promise.all(promises); + return this._hydrationPromise; } invokeHook(hook, ...args) {