Methods

concatenate

static

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 workbox.streams.StreamSource

Returns

Object containing {done: Promise, stream: ReadableStream} 

concatenateToResponse

static

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 workbox.streams.StreamSource

headersInit

Optional

HeadersInit

If there's no Content-Type specified, 'text/html' will be used by default.

Returns

Object containing {done: Promise, response: Response} 

createHeaders

static

createHeaders(headersInit) 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 is available.

Parameter

headersInit

Optional

HeadersInit

If there's no Content-Type specified, 'text/html' will be used by default.

Returns

boolean true, if the current browser meets the requirements for streaming responses, and false otherwise.

isSupported

static

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, and false otherwise.

strategy

static

strategy(sourceFunctions, headersInit) returns workbox.routing.Route~handlerCallback

A shortcut to create a strategy that could be dropped-in to Workbox's router.

On browsers that do not support constructing new ReadableStreams, 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(workbox.routing.Route~handlerCallback)

Each function should return a workbox.streams.StreamSource (or a Promise which resolves to one).

headersInit

Optional

HeadersInit

If there's no Content-Type specified, 'text/html' will be used by default.

Returns

workbox.routing.Route~handlerCallback 

Abstract type

StreamSource

static

(Response, ReadableStream, or BodyInit)