npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-socket-io-wrapper

v0.6.2

Published

A socket.io wrapper for react native.

Downloads

20

Readme

react-native-socket-io-wrapper

A native implementation of Socket.io for React Native.

⚠️ Currently working only on Android, the future commits will focus on iOS.

⚠️ Android uses io.socket:socket.io-client:1.0.1 which supports 2.x (or 3.1.x / 4.x with allowEIO3: true) as described at the compatibility page.

Motivation

After experiencing some performance problems with the JS socket.io library in React Native context, I decided to write a module using the Java solution that can be used in the UI/background threads and by doing so, keeping the JS thread more open to others expensive works and having the performance 💯, and a more stable development experience.

Table of contents

Installation

npm install react-native-socket-io-wrapper

Adding with TurboReactPackage class

In MainApplication.java add the following:

        @Override
        protected List<ReactPackage> getPackages() {
          return Arrays.asList(
            new SocketIoTurboPackage(), // <-- add
            new MainReactPackage()
          );
        }

Usage

import SocketIO from "react-native-socket-io-wrapper";

// ...
const socketIO = new SocketIO('http://127.0.0.1:3000', {
  transports: ['websocket'],
  query: SocketIO.serializeQuery({
    token: 'Bearer JWT',
  }),
});

⚠️ For more info, please see in example of Android the usage of the socket with Hooks and lifecycle.

Methods

connect

socketIO.connect();

Open socket connection.

disconnect

socketIO.disconnect();

Close socket connection.

on

socketIO.on(eventName, callback);

Listen to socket event.

once

socketIO.once(eventName, callback);

Listen once to socket event.

Props

eventName: string callback: Function

emit

socketIO.emit(eventName, data);

Send socket event.

off

socketIO.off(eventName, data);

Remove socket event listener.

Props

eventName: string data: any

connected

socketIO.connected(callback);

Get connection status of socket.

connectedSync

socketIO.connectedSync();

Get connection status of socket.

⚠️ this method are synchronous blocking UI, use it carefully.

getId

socketIO.getId(callback);

Get id of socket.

getIdSync

socketIO.getIdSync();

Get id of socket.

⚠️ this method are synchronous blocking UI, use it carefully.

updateSocketOptions

socketIO.updateSocketOptions(updatedOptions);

Update socket options, this updates general instances paths.

updateSocketOptionsSync

socketIO.updateSocketOptionsSync(updatedOptions);

Update socket options, this updates general instances paths.

⚠️ this method are synchronous blocking UI, use it carefully.

Todos

  • Write tests
  • Implement iOS native module

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT