1.0.16 • Published 2 years ago

react-pusher-codeby v1.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-pusher-codeby

This react-pusher-codeby library supports only ReactJS. Connect directly with https://pusher.codeby.com

Installation

You can use any NPM-compatible package manager, including NPM itself and Yarn.

  yarn add react-pusher-codeby

Then:

  # from root folder
  mkdir -p "src/configs" && cd $_
  vi pusherCodeby.js

pusherCodeby.js

import {PusherCodeby} from "react-pusher-codeby"

const Config = {
    "socketURL": "https://be-mockapi.codeby.com",
    "id": "APP_ID",
    "token": "APP_TOKEN",
}

const pusherCodeby = PusherCodeby(Config)

export {
    pusherCodeby,
}

Usage/Examples

import {pusherCodeby} from "configs/pusherCodeby";
import {useEffect} from "react";

function App() {
    useEffect(() => {
        pusherCodeby.room('room_1').onAny((event, data) => {
            console.log('onAny data', event, data)
        })
        pusherCodeby.room('room_1').on('event_1', (data) =>{
            console.log('on data', data)
        })
        pusherCodeby.on(function (data) {
            console.log('on default', data)
        })
    })
    return (
        <div className="App">
            <button onClick={() => {
                pusherCodeby.room('room_1').emit('event_1', 'data_1');
            }}>
                room_1
            </button>
            <hr/>
            <button onClick={() => {
                pusherCodeby.room('room_1').emit('data_default');
            }}>
                room_default
            </button>
            <hr/>
            <button onClick={() => {
                pusherCodeby.emit('default');
            }}>
                default
            </button>
        </div>
    );
}

export default App;

License

MIT

Authors

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago