Offliner Class
Creates a new Offliner instance.
Item Index
Methods
Properties
Methods
_getConfigURL
-
key
Return a fake URL scheme for a setting.
Parameters:
-
key
StringThe 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
Executes the promise implementation.
Parameters:
-
id
StringThe unique id for the cross promise.
-
order
StringThe order to be executed.
_reject
-
id
-
reason
Rejects a cross promise.
Parameters:
-
id
StringThe unique id for the cross promise.
-
reason
AnyThe value to reject the promise with.
_resolve
-
id
-
value
Resolves a cross promise.
Parameters:
-
id
StringThe unique id for the cross promise.
-
value
AnyThe value to resolve the promise with.
_resolvePromise
-
id
-
status
-
value
Broadcast a message to the clients informing the cross promise to be solved in which status and with which value.
Parameters:
-
id
StringThe unique id for the cross promise.
-
status
StringThe status at which the promise will solve to. Can be
'rejected'
or'solved'
. -
value
AnyThe value for the cross promise.
_sendActivationPending
()
private
Broadcast a message to all clients to indicate there is an update activation ready.
_update
-
fromInstall
Performs a generic update process. It consists into:
- Check for a new version using a middleware.
- Prepare the new version database.
- Evolve the offline cache using the middleware.
- Clean-up.
Parameters:
-
fromInstall
BooleanIndicates if the call comes from the _install method.
Returns:
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:
A serviceworkerware middleware.
get
-
key
Gets a setting for the offliner handler.
Parameters:
-
key
StringThe setting to be retrieved.
set
-
key
-
value
Sets a setting for the offliner handler.
Parameters:
-
key
StringThe setting.
-
value
AnyThe 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