use_service_worker
Reactive ServiceWorker API.
Please check the working example.
Usage
use leptos::prelude::*;
use leptos_use::{use_service_worker_with_options, UseServiceWorkerOptions, UseServiceWorkerReturn};
#[component]
fn Demo() -> impl IntoView {
let UseServiceWorkerReturn {
registration,
installing,
waiting,
active,
skip_waiting,
check_for_update,
} = use_service_worker_with_options(UseServiceWorkerOptions::default()
.script_url("service-worker.js")
.skip_waiting_message("skipWaiting"),
);
view! { }
}
SendWrapped Return
The returned closures check_for_update
and skip_waiting
are sendwrapped functions. They can
only be called from the same thread that called use_service_worker
.
Server-Side Rendering
This function does not support SSR. Call it inside a create_effect
.
Feature
This function is only available if the crate feature
use_service_worker
is enabled