hookly.js

0.9.2 • Public • Published

hookly.js

####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.

Build Status
Circle CI

##Installation

via npm

npm install hookly.js

via bower

bower install hookly.js

#Getting Started

####Start with an working example and build from there

  1. Connect with your Project token - (called token).
hookly.start('{{token}}');
  1. Publish a new message to a channel - realtime updates when the name changes
hookly.notify('#updates', { id: 1538, name: 'New name' })
  1. Listen for messages published to a specific channel - show changes live
hookly.on('#updates', function(data) {
  // data is { id: 1538, name: 'New name' }
});

Advanced Setup

Send updates to specific user

  1. When your user is logged in, add their user identifier (called uid).
hookly.start('{{token}}', '{{uid}}');
  1. Send a message from the current user to another (who is identified by 5a4f67)
hookly.notify('#updates', '5a4f67', { id: 1538, name: 'New name' }

Testing

Send and receive messages without making external connections

  1. Start hookly with an explicit URL (that will points to nothing)
hookly.start('{{token}}', null, 'http://localhost:3000')
  1. Leave all of your other channel listening code alone

  2. 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'}))

Package Sidebar

Install

npm i hookly.js

Weekly Downloads

1

Version

0.9.2

License

MIT

Last publish

Collaborators

  • bnorton