Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@morgan-stanley/composeui-messaging-client

Package Overview
Dependencies
Maintainers
5
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@morgan-stanley/composeui-messaging-client

JavaScript client for ComposeUI's Message Router

  • 0.1.0-alpha.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
5
Weekly downloads
 
Created
Source

@morgan-stanley/composeui-messaging-client

This package contains the client used to connect to the MessageRouter from web modules in ComposeUI.

Setup

Import createMessageRouter from the package

import { createMessageRouter } from "@morgan-stanley/composeui-messaging-client";

Use createMessageRouter() to instantiate the MessageRouter client in a ComposeUI application. It will connect to the MessageRouter hosted by the container when you call connect() on the client.

let client = createMessageRouter();
await client.connect();

Usage

Subscribe to a topic

Use the subscribe method of the client to set a handler on a topic. The message parameter of the handler method contains the payload as a string. The following example parses a JSON payload from the "exampleTopic" topic and logs it to console.

client.subscribe('exampleTopic', (message) => {
    const payload = JSON.parse(message.payload);
    console.log(payload);
    });

Publish a message

Use the publish method of the client to publish a message to a topic. The payload of the message must be a string. The following example creates a JSON string out of an object, and publishes it to the "exampleTopic" topic.

await client.publish('exampleTopic', JSON.stringify(payload));

FAQs

Package last updated on 27 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc