0.0.4 • Published 8 years ago

realy-library v0.0.4

Weekly downloads
5
License
ISC
Repository
-
Last release
8 years ago

Realy

npm package

Create realtime apps, easely.

Get Started now, it's free ➞

Realy is a realtime data delivery platform providing developers everything they need to create, deliver and manage complex projects.

Dead simple API

Realy have just 4 methods at moment. And i'ts very simple to use and get started.

import { init } from 'realy-library';

init('apiKey').then( socket => {

  socket.on('news', ( data ) => {
    console.log(data);
  });

  socket.emit('news', 'Realy is awesome!') 
  // #all users connected on your site will see this message
});

Methods:

/**
 * @name init
 * @description Initialize the event and connects the user
 * with the server to subscribe the events.
 * @return {Promise}
 * @param socket The socket instance, that have the 
 * methods .on, .emit and .disconnect
 */
Realy.init('apikey').then( socket => { 
  socket.on('event', () => { socket.emit('other event')});
  socket.on('other event'=> {
    console.log('All users connected on your application will see this message on console.')
  })
})

/**
 * @name on
 * @description      Register an event
 * @param {String}   event The event name that will be emitted.
 * @param {Function} callback The callback that will be called.
 * @return {void}
 */
Realy.on(event, callback);

/**
 * @name emit
 * @description      Emit an event to all connected users
 * @param {String}   event The event name that will be emitted.
 * @param {Any}      args  The arguments that you can pass in. Optionally.
 * @return {void}
 */
Realy.emit(event,  [...args]);

/**
 * @name disconnect
 * @description      Disconnect the user from your socket. The user
 * will not receive receive and emit events.
 * @return {void}
 */
Realy.disconnect();
0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago