Lightweight implementation of promises

后端 未结 7 1541
独厮守ぢ
独厮守ぢ 2021-02-02 17:09

I am building a simple charting tool. When a user chooses a data source and a chart type, both the data and the script for the specific chart (.js) are loaded and then the code

7条回答
  •  无人及你
    2021-02-02 17:53

    Wanted to throw in my 2¢ as there's been a development here. Promises have arrived natively in JavaScript and will be implemented for FF 30 and Chrome 33 (according to this table).

    Although that's hardly worth mentioning in a place that's usually flooded with "but does it support IE6?", there's a 2kb minified and gzipped polyfill here that is "basically an API remapping of rsvp.js."

    Since jQuery promises aren't really promises, and I agree with this guy that promise syntax is inconsistent across libraries, my view is that native promises are already worth implementing even though your users' browsers probably don't support them yet.


    Edit: After using Promises in the context of Angular and the Firefox addon-SDK, both of which are very similar to Q, I prefer that syntax and have read that it is still faster than the native implementation.

提交回复
热议问题