New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@archetypical/conduit

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@archetypical/conduit

JavaScript client for Conduit

  • 1.0.97
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Conduit Client

Conduit client is a javascript client designed to easily integrate with a Conduit server implementation. The Conduit client is intended to be used with a server Conduit implemented in .net core. Please see the full documentation here.

Installation

Install globally via npm:

npm install -g @archetypical/conduit

Or globally via yarn:

yarn global add @archetypical/conduit

Methods

Once you have established your server side Conduit you can connect to it with a new Conduit client. If you have used the signalr client before, you will recognize a lot of the same methods.

Instantiation

You are able to instantiate a conduit client with the default options:

const conduit = new Conduit();

Or you can provide configuration settings used to change the underlying reconnect behavior.

const conduit = new Conduit({
    logLevel: LogLevel.Error,
    retryInterval: 3000,
    maxConnectionAttempts: 5
});

For more information on these options, please refer to AutoHubConnection.

ApplyFilter

applyFilter(filterName: string, filter: object): Promise<void>

Call applyFilter to provide the server conduit additional data points to more accurately send data to the client.

filterName is expected to be the name of the class used in the server conduit to define filterable data for your users.

filter is the actual filter data to be used by the server conduit to filter calls.

Start

start(): Promise<void>

start initiates a connection with the server Conduit.

On

on<T>(payloadName: string, callback: (data: T) => void): Promise<void>

on adds a callback handler for when a specific payload type is provided.

payloadName is type name of the object pushed by the server Conduit.

callback is the method called whenever a payload of that type is pushed.

Off

off<T>(payloadName: string, callback?: (data: T) => void): void

off removes a handler or all handlers for a specific payload type.

payloadName is the type name of the object pushed by the server Conduit.

callback is the method you want removed whenever a payload of that type is pushed.

Example

import { Conduit } from '@archetypical/conduit'

// Create a new client
const conduit = new Conduit();

// Initiate the connection
await conduit.start();

// Define a callback handler for PageStats
await conduit.on('PageStats', updatePageStats);

// Tell the server you only want updates for specific pages
await conduit.applyFilter('UserFilterData', {
    RecentPages: ['Home', 'About', 'Kittens']
});

Keywords

FAQs

Package last updated on 09 Dec 2022

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