@saber2pr/vscode-webview

0.1.8 • Public • Published

@saber2pr/vscode-webview

vscode webview utils.

yarn add @saber2pr/vscode-webview

Feature

import {
  callService,
  createServiceHandler,
  Pair,
} from '@saber2pr/vscode-webview'

// service type define
export type Services = {
  sayHello: Pair<any, any>
}

const handleServiceMessage = createServiceHandler<Services>({
  sayHello: () => vscode.window.showInformationMessage('Hello! Webview!'),
})

// extension.ts
webviewPanel.webview.onDidReceiveMessage(
  message => handleServiceMessage(webviewPanel, message),
  null,
  context.subscriptions
)

// web
callService<Services, 'sayHello'>('sayHello', null).then(res => {})

Readme

Keywords

none

Package Sidebar

Install

npm i @saber2pr/vscode-webview

Weekly Downloads

0

Version

0.1.8

License

ISC

Unpacked Size

14.2 kB

Total Files

14

Last publish

Collaborators

  • saber2pr