Comments (5)
if people want to use Promise, node v8's promisfy or bluebird's promisfy function is a viable option. 90% of the callbacks plugAPI provides is in the correct form of callback(err, data) => {}; (There are a few that only callback(data) )
I see no benefit of having to rewrite the entire lib to use promises and making people change their existing code to have to use promises.
from plugapi.
from plugapi.
In my opinion, using a standard feature of the platform is a benefit in and of itself.
from plugapi.
As a kind of compromise, maybe methods that take a callback could return a promise if called without a callback argument?
from plugapi.
As an interim solution, I wrote this function:
function toPromise(call)
{
return new Promise(
function(resolve, reject)
{
call(
function(err, data)
{
if(err)
return reject(err);
resolve(data);
}
);
}
);
}
Or, if you want to be slightly more evil:
function toPromise(call)
{
return new Promise(
(resolve, reject) => call((err, data) => err ? reject(err) : resolve(data))
);
}
;)
from plugapi.
Related Issues (20)
- Errors in callback functions passed to playlist methods are mishandled HOT 2
- Should treat URLs as atoms when splitting long chat messages HOT 5
- The advance event when last DJ finishes has djs.length == 2 HOT 2
- getPlaylists callback argument is not a RESTCallback HOT 6
- Chat events mentions are always [] HOT 3
- Duplicate advance event on skip (some times) HOT 2
- Playlist management functions some times silently fail HOT 5
- Cannot read property 'length' of undefined HOT 3
- Bot gets 403 error, restarts at random intervals HOT 7
- addToWaitList throws 403 error when target user has no playlists HOT 3
- Errors trying to perform npm install plugapi HOT 2
- Error after connection with account without playlist HOT 2
- Not sure if playlist functions are working properly
- Unsupported events
- User.language is null HOT 2
- Room Description HOT 8
- Convert name to ID? HOT 8
- Have a bot.
- I'm using your api for a plug bot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugapi.