@loaders.gl/loader-utils
Advanced tools
Comparing version 4.1.3 to 4.1.4
@@ -1,2 +0,2 @@ | ||
const VERSION = typeof "4.1.3" !== 'undefined' ? "4.1.3" : 'latest'; | ||
const VERSION = typeof "4.1.4" !== 'undefined' ? "4.1.4" : 'latest'; | ||
export const JSONLoader = { | ||
@@ -3,0 +3,0 @@ name: 'JSON', |
@@ -13,2 +13,3 @@ import { Stats } from '@probe.gl/stats'; | ||
maxRequests?: number; | ||
debounceTime?: number; | ||
}; | ||
@@ -33,3 +34,3 @@ /** Tracks one request */ | ||
private requestMap; | ||
private deferredUpdate; | ||
private updateTimer; | ||
constructor(props?: RequestSchedulerProps); | ||
@@ -36,0 +37,0 @@ /** |
@@ -10,3 +10,4 @@ import { Stats } from '@probe.gl/stats'; | ||
throttleRequests: true, | ||
maxRequests: 6 | ||
maxRequests: 6, | ||
debounceTime: 0 | ||
}; | ||
@@ -21,3 +22,3 @@ export default class RequestScheduler { | ||
this.requestMap = new Map(); | ||
this.deferredUpdate = null; | ||
this.updateTimer = null; | ||
this.props = { | ||
@@ -82,8 +83,12 @@ ...DEFAULT_PROPS, | ||
_issueNewRequests() { | ||
if (!this.deferredUpdate) { | ||
this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0); | ||
if (this.updateTimer !== null) { | ||
clearTimeout(this.updateTimer); | ||
} | ||
this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), this.props.debounceTime); | ||
} | ||
_issueNewRequestsAsync() { | ||
this.deferredUpdate = null; | ||
if (this.updateTimer !== null) { | ||
clearTimeout(this.updateTimer); | ||
} | ||
this.updateTimer = null; | ||
const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0); | ||
@@ -90,0 +95,0 @@ if (freeSlots === 0) { |
{ | ||
"name": "@loaders.gl/loader-utils", | ||
"version": "4.1.3", | ||
"version": "4.1.4", | ||
"description": "Framework-independent loaders for 3D graphics formats", | ||
@@ -50,6 +50,6 @@ "license": "MIT", | ||
"@babel/runtime": "^7.3.1", | ||
"@loaders.gl/worker-utils": "4.1.3", | ||
"@loaders.gl/worker-utils": "4.1.4", | ||
"@probe.gl/stats": "^4.0.2" | ||
}, | ||
"gitHead": "4313c1f68c25723ab3e906db5a6ac65c2e8ac7b6" | ||
"gitHead": "e5b4fe1845c1483addfc4c3d630f1617595efbae" | ||
} |
@@ -15,2 +15,3 @@ import {Stats} from '@probe.gl/stats'; | ||
maxRequests?: number; | ||
debounceTime?: number; | ||
}; | ||
@@ -26,6 +27,11 @@ | ||
id: 'request-scheduler', | ||
// Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing | ||
/** Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing. */ | ||
throttleRequests: true, | ||
// The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit. | ||
maxRequests: 6 | ||
/** The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit. */ | ||
maxRequests: 6, | ||
/** | ||
* Specifies a debounce time, in milliseconds. All requests are queued, until no new requests have | ||
* been added to the queue for this amount of time. | ||
*/ | ||
debounceTime: 0 | ||
}; | ||
@@ -53,3 +59,3 @@ | ||
private requestMap: Map<Handle, Promise<RequestResult>> = new Map(); | ||
private deferredUpdate: any = null; | ||
private updateTimer: ReturnType<typeof setTimeout> | null = null; | ||
@@ -138,5 +144,6 @@ constructor(props: RequestSchedulerProps = {}) { | ||
_issueNewRequests(): void { | ||
if (!this.deferredUpdate) { | ||
this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0); | ||
if (this.updateTimer !== null) { | ||
clearTimeout(this.updateTimer); | ||
} | ||
this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), this.props.debounceTime); | ||
} | ||
@@ -146,4 +153,6 @@ | ||
_issueNewRequestsAsync() { | ||
// TODO - shouldn't we clear the timeout? | ||
this.deferredUpdate = null; | ||
if (this.updateTimer !== null) { | ||
clearTimeout(this.updateTimer); | ||
} | ||
this.updateTimer = null; | ||
@@ -150,0 +159,0 @@ const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
450280
6670
+ Added@loaders.gl/worker-utils@4.1.4(transitive)
- Removed@loaders.gl/worker-utils@4.1.3(transitive)