realdb
v0.0.2
Published
The key-value cloud database for humans.
Downloads
8
Readme
Realpub
Make your web app realtime easily.
Realpub is a realtime data delivery platform providing developers everything they need to create, deliver and manage complex projects.
Dead simple API
Realpub have just 4 methods at moment. And i'ts very simple to use and get started.
import { init } from 'realpub';
init('apiKey').then( socket => {
socket.on('news', ( data ) => {
console.log(data);
});
socket.emit('news', 'Realpub 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
*/
Realpub.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}
*/
Realpub.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}
*/
Realpub.emit(event, [...args]);
/**
* @name disconnect
* @description Disconnect the user from your socket. The user
* will not receive receive and emit events.
* @return {void}
*/
Realpub.disconnect();