cloudvision-grpc-web
TypeScript icon, indicating that this package has built-in type declarations

5.0.2 • Public • Published

cloudvision-grpc-web

A grpc-web client for requesting CloudVision data from the frontend. This libraries exposed functions and utils that convert the grpc-web calls to Observable streams that can be manipulated using RXJS.

The package expects protobuf definitions to be generated via ts-proto

Installation

npm install cloudvision-grpc-web

or

yarn install cloudvision-grpc-web

Usage

import { fromResourceGrpcInvoke } from 'cloudvision-grpc-web';

import { DeviceServiceGetAllDesc, DeviceStreamRequest } from '../generated/arista/inventory.v1/services.gen';

const requestAllMessage = DeviceStreamRequest.fromPartial({});

const grpcRequest = fromResourceGrpcInvoke(DeviceServiceGetAllDesc, {
  host: 'http://cvphost',
  request: { ...requestAllMessage, ...DeviceServiceGetAllDesc.requestType },
});

// Will print out each data message as it arrives
grpcRequest.data.subscribe({
  next: (val) => console.log('data', val))
})

// Will print out any Grpc metadata or errors as they happen
grpcRequest.messages.subscribe({
  next: (val) => console.log('control message', val))
})

Package Sidebar

Install

npm i cloudvision-grpc-web

Weekly Downloads

17

Version

5.0.2

License

MIT

Unpacked Size

422 kB

Total Files

25

Last publish

Collaborators

  • geiger-platform