Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected onLoaded(payload: ArrayBufferLike | {}) {
this.state = TileLoaderState.Loaded;
this.payload = payload;
if ((payload as ArrayBufferLike).byteLength !== undefined) {
if ((payload as ArrayBufferLike).byteLength === 0) {
this.onDone(TileLoaderState.Ready);
return;
}
}
// Object is empty
if ((payload as {}) === {}) {
this.onDone(TileLoaderState.Ready);
return;
}
// TBD: we might suspend decode if tile is not visible ... ?
this.startDecodeTile();
}
protected onLoaded(payload: ArrayBufferLike | {}) {
this.state = TileLoaderState.Loaded;
this.payload = payload;
if ((payload as ArrayBufferLike).byteLength !== undefined) {
if ((payload as ArrayBufferLike).byteLength === 0) {
this.onDone(TileLoaderState.Ready);
return;
}
}
// Object is empty
if ((payload as {}) === {}) {
this.onDone(TileLoaderState.Ready);
return;
}
// TBD: we might suspend decode if tile is not visible ... ?
this.startDecodeTile();
}
.then(tileInfo => {
if (requestController.signal.aborted) {
// our flow is cancelled, silently return
return;
}
this.tileInfo = tileInfo;
this.onDone(TileLoaderState.Ready);
})
.catch(error => {
tileLoader.loadAndDecode().then(loaderState => {
if (loaderState === TileLoaderState.Ready) {
resolve(tileLoader.tileInfo);
} else {
reject(
new Error(`TileDataSource#getInfoTile wrong final state: ${loaderState}`)
);
}
});
});
get isFinished(): boolean {
return (
this.state === TileLoaderState.Ready ||
this.state === TileLoaderState.Canceled ||
this.state === TileLoaderState.Failed
);
}