1.0.1 • Published 8 years ago

seneca-asyncify v1.0.1

Weekly downloads
4
License
GPL-3.0
Repository
github
Last release
8 years ago

asyncify-seneca

Adds async methods for seneca.

Methods

addAsync(def, generator) - uses co to handle the generator function.

actAsync(def) - uses bluebird.promisify, returns a promise.

Usage

const asyncifySeneca = require('seneca-asyncify');
const seneca = require('seneca');

const s = asyncifySeneca(seneca)
  .use(...);

s.addAsync('role:sms,cmd:send', function*(args) => {
  const result = yield someAsyncThing();
  yield s.actAsync('role:email,cmd:send')
    .catch((err) => /*handle error*/);
  return { done: true, result: result };
});

TODO

actAsync could just return a thunk so that we can remove the bluebird dep.

1.0.1

8 years ago

1.0.0

8 years ago