4 ms·
All I have to say guys; promises + generators. My god, it's absolutely delicious. Seriously, just learn it. Get your --harmony flag on. It will be in browsers
by babby 13y ago
All I have to say guys; promises + generators. My god, it's absolutely delicious.
Seriously, just learn it. Get your --harmony flag on. It will be in browsers soon enough as well. It's literally the future of javascript and having converted some of my codebase to promises + generators instead of just promises. Wow. It felt amazing. Suddenly everything doesn't look like spaghetti.
I use bluebird for promises and a custom dev fork of Coffeescript that allows for generators. You do have to wrap your anonymous functions with "Promise.coroutine", but thats really it. You could always just not even use promises, and go plain generators too.
- 727374 13y agoIf I promisify some code with bluebird, can I use it with Mongoose's built in promises? Or will promises from different libraries explode when they touch?
- babby 13y agoWell promises are suppose to be compatible with one another due to adhering to rules. Should be A-OK. Bluebird is just, at the moment, the most performant Promise library, and they seem to be building their API as close to what native Promises will be like. You could really use any promise library and it wouldn't matter much, perhaps use the one that mongoose uses if it's an issue.