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
- Host: GitHub
- URL: https://github.com/fixate/asyncify-seneca
- Owner: fixate
- License: gpl-3.0
- Created: 2016-05-26T13:40:06.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-09T09:56:49.000Z (almost 9 years ago)
- Last Synced: 2025-02-04T11:17:16.618Z (3 months ago)
- Language: JavaScript
- Size: 126 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.