UNPKG

@speckle/objectloader2

Version:

This is an updated objectloader for the Speckle viewer written in typescript

47 lines 1.03 kB
export class DeferredBase { promise; resolve; reject; item; id; expiresAt; // Timestamp in ms ttl; // ttl in ms constructor(ttl, id, expiresAt) { this.expiresAt = expiresAt; this.ttl = ttl; this.id = id; this.promise = new Promise((resolve, reject) => { this.resolve = resolve; this.reject = reject; }); } getId() { return this.id; } getItem() { return this.item; } getPromise() { return this.promise; } isExpired(now) { return this.item !== undefined && now > this.expiresAt; } setAccess(now) { this.expiresAt = now + this.ttl; } found(value) { this.item = value; this.resolve(value.base); } done(now) { if (this.item) { this.resolve(this.item.base); } if (this.isExpired(now)) { return true; } return false; } } //# sourceMappingURL=deferredBase.js.map