0.0.1 • Published 6 months ago

sw-shared-functions v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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>

0.0.1

6 months ago