Skip to content

Instantly share code, notes, and snippets.

View jorgecuesta's full-sized avatar

Jorge S. Cuesta jorgecuesta

View GitHub Profile
@jorgecuesta
jorgecuesta / sample.js
Created July 5, 2017 03:57
Hemera.js Promise support
const Hemera = require('nats-hemera');
const nats = require('nats').connect();
const hemera = new Hemera(nats, {logLevel: 'fatal'});
const actionWithPromiseSupport = function(hemera) {
const act = hemera.act;
return function(pattern, callback) {
if (callback || pattern.pubsub$) return act.call(hemera, pattern, callback);
return new Promise((resolve, reject) => {
act.call(hemera, pattern, (err, resp) => {