workbox-streams
Methods
concatenate
concatenate(sourcePromises) returns Object containing {done: Promise, stream: ReadableStream}
Takes multiple source Promises, each of which could resolve to a Response, a ReadableStream, or a BodyInit.
Returns an object exposing a ReadableStream with each individual stream's data returned in sequence, along with a Promise which signals when the stream is finished (useful for passing to a FetchEvent's waitUntil()).
Parameter |
|
---|---|
sourcePromises |
Array of Promise containing module:workbox-streams.StreamSource |
- Returns
-
Object containing {done: Promise, stream: ReadableStream}
concatenateToResponse
concatenateToResponse(sourcePromises, headersInit) returns Object containing {done: Promise, response: Response}
Takes multiple source Promises, each of which could resolve to a Response, a ReadableStream, or a BodyInit, along with a HeadersInit.
Returns an object exposing a Response whose body consists of each individual stream's data returned in sequence, along with a Promise which signals when the stream is finished (useful for passing to a FetchEvent's waitUntil()).
Parameter |
|
---|---|
sourcePromises |
Array of Promise containing module:workbox-streams.StreamSource |
headersInit |
Optional HeadersInit If there's no |
- Returns
-
Object containing {done: Promise, response: Response}
isSupported
isSupported() returns boolean
This is a utility method that determines whether the current browser supports
the features required to create streamed responses. Currently, it checks if
ReadableStream
can be created.
- Returns
-
boolean
true
, if the current browser meets the requirements for streaming responses, andfalse
otherwise.
strategy
strategy(sourceFunctions, headersInit) returns module:workbox-routing~handlerCallback
A shortcut to create a strategy that could be dropped-in to Workbox's router.
On browsers that do not support constructing new ReadableStream
s, this
strategy will automatically wait for all the sourceFunctions
to complete,
and create a final response that concatenates their values together.
Parameter |
|
---|---|
sourceFunctions |
Array of function({event, request, url, params}) An array of functions similar to module:workbox-routing~handlerCallback but that instead return a module:workbox-streams.StreamSource (or a Promise which resolves to one). |
headersInit |
Optional HeadersInit If there's no |
Abstract type
StreamSource
(Response, ReadableStream, or BodyInit)