workbox-streams

Types

StreamsHandlerCallback()

workbox-streams.StreamsHandlerCallback(
  __namedParameters: RouteHandlerCallbackOptions,
)

Parameters

Returns

StreamSource

Enum

Response

ReadableStream

BodyInit

Methods

concatenate()

workbox-streams.concatenate(
  sourcePromises: Promise<StreamSource>[],
)

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()).

Parameters

Returns

  • object

    }

concatenateToResponse()

workbox-streams.concatenateToResponse(
  sourcePromises: Promise<StreamSource>[],
  headersInit: HeadersInit,
)

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()).

Parameters

  • sourcePromises

    Promise<StreamSource>[]

  • headersInit

    HeadersInit

Returns

  • object

    }

isSupported()

workbox-streams.isSupported()

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()

workbox-streams.strategy(
  sourceFunctions: StreamsHandlerCallback[],
  headersInit: HeadersInit,
)

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.

Parameters