####Hookly funnels messages to your front-end application in realtime.
Receive realtime messages sent from anywhere For example, after successful update to data, show changes to the other collaborators. Upon completion of background work update the UI with the result. Deliver webhooks to your client-side javascript application.
##Installation
via npm
npm install hookly.js
via bower
bower install hookly.js
#Getting Started
####Start with an working example and build from there
- Connect with your Project token - (called
token
).
hookly.start('{{token}}');
- Publish a new message to a channel - realtime updates when the name changes
hookly.notify('#updates', { id: 1538, name: 'New name' })
- Listen for messages published to a specific channel - show changes live
hookly.on('#updates', function(data) {
// data is { id: 1538, name: 'New name' }
});
- When your user is logged in, add their user identifier (called
uid
).
hookly.start('{{token}}', '{{uid}}');
- Send a message from the current user to another (who is identified by
5a4f67
)
hookly.notify('#updates', '5a4f67', { id: 1538, name: 'New name' }
- Start hookly with an explicit URL (that points to nothing)
hookly.start('{{token}}', null, 'http://localhost:3000')
-
Leave all of your other channel listening code alone
-
Send a message to your channel listeners explicitly call the hookly adapter with a
payload
- Send a
slug
as the channel - Send a
body
as the object to pass to the channel listener - Send a
kind
of 'local'
hookly.adapter.call(JSON.stringify({slug: '#updates', body: {id: 5}, kind: 'local'}))