Socket
Book a DemoInstallSign in
Socket

@ovos-media/react-realtime

Package Overview
Dependencies
Maintainers
16
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ovos-media/react-realtime

Official React bindings for Realtime

latest
npmnpm
Version
0.0.2
Version published
Maintainers
16
Created
Source

React Realtime

Official React bindings for Realtime.

Installation

React Realtime requires React 16 or later.

npm install --save ovos-media/react-realtime

This assumes that you’re using npm package manager with a module bundler like Webpack or Browserify to consume CommonJS modules.

How Does It Work?

// App.js

import React, { Component } from 'react';

import { Provider as RealtimeProvider } from '@ovos-media/react-realtime';
import realtime from '@ovos-media/play-live-realtime-ws-client';

realtime.init({
	host: 'localhost',
	port: '3215',
	user: {}, // optional, user defined json data
	handshakeCallback : function(data){} // optional, handshake callback function
}, () => {
	console.log('success');
});


class App extends Component {
  render() {
    return (
			<RealtimeProvider realtime={realtime}>
				{children}
			</RealtimeProvider>
		);
	}
}

export default App;
// MyButton.js

import React, { Component } from 'react';

import { withRealtime } from '@ovos-media/react-realtime';


class MyButton extends Component {
  render() {
    return (
			<button onClick={this.pingRealtimeService}>
		);
	}

	pingRealtimeService = () => {
		const { realtime } = this.props;
		realtime.request("connector.entryHandler.ping", {
			foo: "bar"
		}, function(response) {
			console.log(response);
		});
	}
}

export default withRealtime()(MyButton);

License

MIT

Keywords

react

FAQs

Package last updated on 20 Nov 2018

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