成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

[gist]Why Promises will make async easy

EasonTyler / 2763人閱讀

摘要:有許多理由你將會需要用到好吧先來解釋一下什么是。這類似于我們經(jīng)常使用的返回的那個(gè)玩意比如想要在對請求來的數(shù)據(jù)做加工

from http://oyanglul.us

What is Promises

Promise is a proxy for a value not knowing when its creation time. It provide 2 Methods then and catch, which return promise so they can be chained.

Promise.prototype.then(onFulfilled, onRejected)

Appends fullfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.

Promise.prototype.catch(onRejected)

Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.

Why Promises

there are so many reasons you should use promise in you client rich project if you are not using any MV* frameworks.

有許多理由你將會需要用到 Promises. 好吧先來解釋一下什么是 Promises 。 這類似于我們經(jīng)常使用的 jQuery.ajax() 返回的那個(gè)玩意 – Deferreds.

比如想要在對 ajax 請求來的數(shù)據(jù)做加工

? $.ajax("yourdata.url").then(function(data){
????? // do something with your data
? })

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/85259.html

相關(guān)文章

  • promise, async, await, execution order

    摘要: async can be transformed to promise. So, if we want to understand async, we have to understand promise first. Promise Normally, promise is easy to understand, especially when using like this: p...

    neuSnail 評論0 收藏0
  • JavaScript Promise API

    摘要:我們使用關(guān)鍵字和提供的和回調(diào)函數(shù)來創(chuàng)建新的根據(jù)異步任務(wù)的返回結(jié)果,開發(fā)者可以在回調(diào)函數(shù)體的內(nèi)部手動調(diào)用或者。第一個(gè)方法的回調(diào)函數(shù)接收方法里的值當(dāng)被時(shí),會調(diào)用回調(diào)方法。如果被,而方法在之后,那回調(diào)函數(shù)永遠(yuǎn)不會被執(zhí)行。 盡管同步代碼易于追蹤和調(diào)試,但異步代碼普遍在性能和靈活性上更具優(yōu)勢。Why hold up the show when you can trigger numerous r...

    peixn 評論0 收藏0
  • Koa / Co / Bluebird or Q / Generators / Promises /

    摘要:經(jīng)常游蕩在的我總能發(fā)現(xiàn)許多好問題和好答案。盡管網(wǎng)絡(luò)上有著各式各樣的關(guān)于該主題的指導(dǎo),但涉及到在各種情景下的最佳實(shí)踐,或者較好實(shí)踐的方面還是不夠清晰。我寄希望于針對我這篇裹腳布式問題的回復(fù)可以改變這一現(xiàn)狀。我感覺因此收益的絕對不止是我一個(gè)人。 經(jīng)常游蕩在 SO 的我總能發(fā)現(xiàn)許多好問題和好答案。它們的好不僅僅在于知識的價(jià)值,更可貴之處在于如何表達(dá):如何提問/如何回答。不久前我在 SF...

    xingpingz 評論0 收藏0
  • [gist]pure and secure javascript oauth with yql

    from http://oyanglul.us It would be awesome if we can use OAuth in JavaScript purely in client side. before start to do that, please let me e...

    ityouknow 評論0 收藏0
  • js錯(cuò)誤處理權(quán)威指北

    摘要:第一個(gè)是,是你傳遞給異常的構(gòu)造函數(shù)的參數(shù),比如你可以使用屬性來訪問到該消息第二個(gè)參數(shù)是異常堆棧跟蹤,非常重要。異常產(chǎn)生后能在后端正確處理是的關(guān)鍵部分。我將向你展示自定義構(gòu)造函數(shù)和錯(cuò)誤代碼的方法,我們可以輕松地將其傳遞給前端或任何調(diào)用者。 By Lukas Gisder-Dubé | nov 14, 2018 原文 接著我上一篇文章,我想談?wù)劗惓!N铱隙阒耙猜犨^——異常是個(gè)好東西。一...

    lykops 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<