npm.io
1.0.2 • Published 56m ago

@univerjs/rpc

Licence
Apache-2.0
Version
1.0.2
Deps
1
Size
128 kB
Vulns
0
Weekly
0
Stars
14.4K

@univerjs/rpc

npm version license downloads

@univerjs/rpc provides a browser-friendly RPC layer for communicating between the main thread and workers or other message-based runtimes.

Package Overview

Package UMD global CSS Locales Facade entry
@univerjs/rpc UniverRpc No No No

Installation

pnpm add @univerjs/rpc
# or
npm install @univerjs/rpc

Keep all @univerjs/* packages on the same version.

Usage

import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';

const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
univer.registerPlugin(UniverRPCMainThreadPlugin, { workerURL: worker });
univer.onDispose(() => worker.terminate());

The referenced worker module must create its own Univer instance and register UniverRPCWorkerThreadPlugin; see the browser worker example.

Exported plugin classes:

  • UniverRPCMainThreadPlugin
  • UniverRPCWorkerThreadPlugin

Resources

Keywords