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

socketcluster-wrapper-client

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socketcluster-wrapper-client

## Usages

  • 1.1.8
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-41.18%
Maintainers
0
Weekly downloads
 
Created
Source

Socketcluster Client Wrapper

Usages

Web

// for browser
import 'socketcluster-wrapper-client/dist';

// for react or other import module
import SocketClient from 'socketcluster-wrapper-client';
const options = {
  secure: true,
  authType: 'ws'
}
// options.secure to use https
// options.authType: using authentication via http or ws.

// apiKey: indentity client request can generate from dashboard
const client = new SocketClient(apiKey, options)
const socket = await client.connect()

// other usage can follow https://github.com/SocketCluster/socketcluster-client#transmit-data

React Native

import SocketClient from 'socketcluster-wrapper-client';
import AuthEngine from 'socketcluster-wrapper-client/authEngine';

const options = {
  secure: true,
  authType: 'ws',
  authEngine: new AuthEngine()
}
// options.secure to use https
// options.authType: using authentication via http or ws.

// apiKey: indentity client request can generate from dashboard 
const client = new SocketClient(apiKey, options)
const socket = await client.connect()

// Connect with channel and listen stream data
// using for await (let data of channel) is not working with React Native
const channel = socket.subscribe('realtime');

const iterator = channel[Symbol.asyncIterator]();
const result = [];
while (result.length < Infinity) {
    const { value, done } = await iterator.next();
    if (done) break;
    console.log(value);
}

// other usage can follow https://github.com/SocketCluster/socketcluster-client#transmit-data

Additional to support es6 async iterable

  yarn add --dev @babel/plugin-proposal-async-generator-functions
  npm install --save-dev @babel/plugin-proposal-async-generator-functions

Add Line bellow to babel.config.js

  "plugins": ["@babel/plugin-proposal-async-generator-functions"]

Socket Listener

const channel = socket.subscribe('realtime');
for await (let data of channel) {
  console.log(data);
}

NOTE Additional installation AsyncStorage

FAQs

Package last updated on 03 Jul 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