Skip to content

Aaronphy/vscode-webview-rpc

Repository files navigation

Welcome to vscode-webview-prc 👋

Version Prerequisite License: MIT

a rpc lib for vscode webview extension development

Prerequisites

  • node >=10

Install

yarn add vscode-webview-rpc

Usage

extension rpc

import * as vscode from 'vscode';
import { ExtensionRPC } from 'vscode-webview-rpc';


const panel = vscode.window.createWebviewPanel(
			'EditPanel',
			'Blog Editing',
			column || vscode.ViewColumn.One,
			getWebviewOptions(extensionUri),
	);

const RPC = new ExtensionRPC(panel.webview);

RPC.on('log',(e)=>{
  console.log(e);
  return Promise.resolve();
});

webview rpc

import { WebviewRPC } from 'vscode-webview-rpc';

declare var acquireVsCodeApi: any;

let RPC:WebviewRPC;

(()=>{
   RPC = new WebRPC(window, vscode);
   setTimeout(()=>{
     RPC.emit('log',["hello world"]);
   },2000);
})();

Author

👤 aaronphy

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

About

a rpc lib for vscode extension development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published