5 ms·
Native Promises already landed Chrome 32 and Q still does not support native promises. Bluebird delegate to native if supported. Promises can be used as flow c
by lightblade 13y ago
Native Promises already landed Chrome 32 and Q still does not support native promises. Bluebird delegate to native if supported.
Promises can be used as flow control, but more importantly, it's an object that encapsulates asynchronous mechanics.
I like to see how async can launch an asynchronous operation, then allow listeners to be attached later to capture the result. Now, you may say that if you want to attach listeners to capture result, you'll want to use event emitters. True, but event emitters has its own problem because event emitting and attach listeners are synchronous. What if the event was emitted before any body has a chance to attach listener to it?
Promises does not have these issues.
- domenicd 13y agoThis is false. Bluebird does not and never will delegate to native promises.
- lightblade 13y agook... then can you explain what's happening here: https://github.com/petkaantonov/bluebird/blob/master/js/browser/bluebird.js#L27 https://github.com/petkaantonov/bluebird/blob/master/js/brow... Where the line checks for `window.Promise`
- jhrobert 13y agoUsing async, if you want something to allow listeners to be attached later: var outcome = Boxon(); fs.readFile( "test.txt", outcome ); // Attach listener later: outcome( function( err, content ){ ... } ); See https://github.com/JeanHuguesRobert/l8/wiki/AboutBoxons https://github.com/JeanHuguesRobert/l8/wiki/AboutBoxons Boxon objects are light compared to promises, but they interop well. Best of both worlds!