API Docs for:
Show:

Offliner Class

Creates a new Offliner instance.

Methods

_getConfigURL

(
  • key
)
private

Return a fake URL scheme for a setting.

Parameters:

  • key String

    The setting.

Returns:

a fake URL scheme for the setting.

_initialize

() private

Initializes the current version and active cache for the first time.

_install

() private

Determine if the worker should prefetch or update after (re)installing the service worker.

_processMessage

() private

Process the different messages that can receive the worker.

_receiveCrossPromise

(
  • id
  • order
)
private

Executes the promise implementation.

Parameters:

  • id String

    The unique id for the cross promise.

  • order String

    The order to be executed.

_reject

(
  • id
  • reason
)
private

Rejects a cross promise.

Parameters:

  • id String

    The unique id for the cross promise.

  • reason Any

    The value to reject the promise with.

_resolve

(
  • id
  • value
)
private

Resolves a cross promise.

Parameters:

  • id String

    The unique id for the cross promise.

  • value Any

    The value to resolve the promise with.

_resolvePromise

(
  • id
  • status
  • value
)
private

Broadcast a message to the clients informing the cross promise to be solved in which status and with which value.

Parameters:

  • id String

    The unique id for the cross promise.

  • status String

    The status at which the promise will solve to. Can be 'rejected' or 'solved'.

  • value Any

    The value for the cross promise.

_sendActivationPending

() private

Broadcast a message to all clients to indicate there is an update activation ready.

_update

(
  • fromInstall
)
Promise private

Performs a generic update process. It consists into:

  1. Check for a new version using a middleware.
  2. Prepare the new version database.
  3. Evolve the offline cache using the middleware.
  4. Clean-up.

Parameters:

  • fromInstall Boolean

    Indicates if the call comes from the _install method.

Returns:

Promise:

A Promise resolving in the vertion to update or rejecting if there is no update needed (reason = 'no-update-needed').

asMiddleware

() Object

Returns an object to be used with serviceworkerware. Once the method is called once, the method will allways return the same object.

Returns:

Object:

A serviceworkerware middleware.

get

(
  • key
)
private

Gets a setting for the offliner handler.

Parameters:

  • key String

    The setting to be retrieved.

set

(
  • key
  • value
)
private

Sets a setting for the offliner handler.

Parameters:

  • key String

    The setting.

  • value Any

    The value to be set.

standalone

()

Installs the service worker in stand-alone mode.

Properties

_isMiddleware

Boolean private

Mark the instance to be used as middleware.

Default: false

_isStarted

Boolean private

Prevent the worker to be installed twice.

Default: false

_middleware;

Object private

The middleware implementation for serviceworkerware.

Default: null

_updateControl

UpdateControl private

The global update control.

fetch

FetchConfig

API to configure the fetching pipeline.

prefetch

PrefetchConfig

API to configure the prefetch process.

update

UpdateConfig

API to configure the update process.