sw-shared-functions
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

sw-shared-functions

Shared functions between client and service worker

Installation

npm i sw-shared-functions

Usage

To share

import { share } from 'sw-shared-functions';

export class HelloService {
  sayHello(name: string): string {
    return `Hello, ${name}`;
  }
}

share(new HelloService());

To load

import { load } from 'sw-shared-functions';
import type { HelloService } from '../services/hello.service';

const helloServ = await load<HelloService>();
console.log(await helloServ.sayHello('World!'));

License

MIT. Copyright (c) Kyaw Swar Thwin <myanmarunicorn@gmail.com>

/sw-shared-functions/

    Package Sidebar

    Install

    npm i sw-shared-functions

    Weekly Downloads

    2

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    48 kB

    Total Files

    11

    Last publish

    Collaborators

    • kyawswarthwin