@paraswap/subscription-service-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Subscription-service-client

Simple client for Http-Subscription-Service

Table of Contents

Install

Install the package from NPM:

npm install @paraswap/subscription-service-client

Usage

import { HttpSubscriptionService } from '@paraswap/subscription-service-client;

// Create na instance
const client = new HttpSubscriptionService(HTTP_SUBSCRIPTION_SERVICE_WS_URL)

// Subscribe for connection event (this event will be triggered as soon as we get a connection to the `http-subscription-service`)
client.on('opened', () => {
      // Create a subscription
      HttpSubscriptionService.subscribe(
        {
          pollInterval: 5000, // Provide a polling interval for your subscription
          requestOptions: { // Request options (AxiosRequestOptions)
            url: `test.com/getWeather`
          },
        },
        (state: { data: WeatherResponse }) => { // Callback for data
          console.log(`Current temp: ${weather.temp}`);
        },
      );
});

Readme

Keywords

none

Package Sidebar

Install

npm i @paraswap/subscription-service-client

Weekly Downloads

36

Version

1.0.3

License

MIT

Unpacked Size

33.8 kB

Total Files

24

Last publish

Collaborators

  • 0xsokka
  • danylo_kanievskyi
  • jascier
  • aburkut
  • mounibec
  • ps_admin
  • velenir
  • mwamedacen