/sw-shared-functions

Shared functions between client and service worker

Primary LanguageTypeScriptMIT LicenseMIT

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>