Class ImageFetch
Defined in: image-worker/fetch.ts:32
Main-thread client for an ImageWorker. Sends image load requests to a Worker or SharedWorker running an ImageWorker.
In FastBoot/SSR, or when constructed with a null worker, ImageFetch skips worker communication entirely: ImageFetch.load resolves immediately with the given url.
A plain Worker is only accepted when running in a TESTING build; production usage requires a SharedWorker.
Constructors
Constructor
new ImageFetch(worker): ImageFetch;Defined in: image-worker/fetch.ts:44
Parameters
worker
| Worker | SharedWorker | null
the Worker or SharedWorker running an ImageWorker, or null to disable worker communication (e.g. in FastBoot/SSR).
Returns
ImageFetch
Methods
_send()
_send(event): void;Defined in: image-worker/fetch.ts:93
Parameters
event
RequestEventData
Returns
void
cleanupRequest()
cleanupRequest(url): Deferred<string> | undefined;Defined in: image-worker/fetch.ts:86
Parameters
url
string
Returns
Deferred<string> | undefined
load()
load(url): Promise<string>;Defined in: image-worker/fetch.ts:116
Requests that the given image url be loaded by the connected ImageWorker, resolving with an object url for the fetched image's blob once the worker responds (or immediately with the original url, in SSR/FastBoot or when this instance was constructed with a null worker).
The resolved object url is cached in-memory by source url on this instance, so subsequent calls for the same url resolve immediately without another round-trip to the worker.
Calling load again for a url that is already in-flight (not yet cached) on this instance replaces the pending request rather than joining it — only the most recently issued call for a given url will resolve.
Parameters
url
string
Returns
Promise<string>
Properties
cache
cache: Map<string, string>;Defined in: image-worker/fetch.ts:37
channel
channel: MessageChannel;Defined in: image-worker/fetch.ts:36
pending
pending: Map<string, Deferred<string>>;Defined in: image-worker/fetch.ts:35
threadId
threadId: string;Defined in: image-worker/fetch.ts:34
worker
worker:
| Worker
| SharedWorker;Defined in: image-worker/fetch.ts:33