1.0.4 • Published 7 years ago

unloq-events v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

UNLOQ.io Node.js module for real-time UNLOQ events

Full documentation will be available soon

Full docs: https://docs.unloq.io

Example available in folder example/

Usage:
const UnloqEvents = require('unloq-events');

const client = new UnloqEvents({
  key: 'YOUR_API_KEY'
});

// Subscribe to namespace modifications (eg: IAM & Permission changes)
clientObj
  .subscribe(clientObj.NAMESPACE.IAM, (data) => {
    console.log(`Event occurred: ${data.type}`);
    console.log(data.payload);
  }).catch((e) => {
    console.warn(`Something bad happened`, e);
  });
  
setTimeout(() => {
  // Or unsubscribe from a namespace
  clientObj.unsubscribe(clientObj.NAMESPACE.IAM);
}, 5000);

// OR have a specific subscription
function onEvent(data) {
  console.log(`Received: ${data.type}`):
  console.log(data.payload);
}
clientObj.subscribe(clientObj.NAMESPACE.IAM, /permission\.save/g, onEvent);

// Or unsubscribe a specific callback
setTimeout(() => {
  clientObj.unsubscribe(clientObj.NAMESPACE.IAM, onEvent);
}, 3000);
  
clientObj.on('error', (e) => {
  console.log("Error", e);
});

Current supported namespaces:

NAMESPACE.IAM // namespace for IAM & Permissions

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago