@divertise-asia/bs-service-worker

0.0.7 • Public • Published

bs-service-worker

Buckle script service-worker binding

Status

  • Master build
  • Release npm-publish

Installation

  1. npm install @divertise-asia/bs-service-worker --save
  2. Add @divertise-asia/bs-service-worker to bsconfig.json
  3. Enjoy!

Example

open BsServiceWorker;
switch(ServiceWorker.maybeServiceWorker) {
  | None => {
    Js.log("[App] Browser does *not* support service workers");
  }
  | Some(worker) => {
    Js.log("[App] Browser supports service workers");
    open ServiceWorker;
    Js.Promise.(worker->registerOnLoad("demo-sw.js")
      |> then_((b:ServiceWorker.Registration.t) => {
        Js.log("[App] ServiceWorker registration successful with scope: " ++ b##scope);
        resolve(Some(b));
      })
      |> catch(e => {
        Js.log2("[App] ServiceWorker registration failed: ", e);
        resolve(None)
      })
    ) |> ignore;
  }
};

More examples can be found at @divertise-asia/bs-service-worker-examples

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i @divertise-asia/bs-service-worker

    Weekly Downloads

    0

    Version

    0.0.7

    License

    MIT

    Unpacked Size

    10.9 kB

    Total Files

    12

    Last publish

    Collaborators

    • divertiseadmin
    • song_divertise