Module Service_worker.Container

Service worker containers.

type t

The type for ServiceWorkerContainer objects.

val of_navigator : Brr.Navigator.t -> t

of_navigator n is the service worker container of navigator n.

val as_target : t ->

as_target c is c as an event target.

val controller : t -> service_worker option

controller c is the active service worker if any.

val ready : t -> Registration.t Fut.or_error

ready c is a future that resolves when a service worker is active.

type register_opts

The type for worker registration options.

val register_opts : ?⁠scope:Jstr.t -> ?⁠type':Worker.Type.t -> ?⁠update_via_cache:Update_via_cache.t -> unit -> register_opts

register_opts ~scope ~type ~update_via_cache () are registration options with given properties.

val register : ?⁠register_opts:register_opts -> t -> Jstr.t -> Registration.t Fut.or_error

register c script_uri ~register_opts creates or updates a registration with script_url.

val get_registration : t -> Jstr.t option -> Registration.t option Fut.or_error

get_registration c url is the registration for url (if any).

val get_registrations : t -> Registration.t list Fut.or_error

get_registrations c are all the registration fo c.

val start_messages : t -> unit

start_messages c starts the flow of messages from the service worker to the pages.