An open API service indexing awesome lists of open source software.

https://github.com/fixate/asyncify-seneca

Async methods for Seneca
https://github.com/fixate/asyncify-seneca

Last synced: 2 months ago
JSON representation

Async methods for Seneca

Awesome Lists containing this project

README

        

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

```javascript
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.