国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

[gist]Why Promises will make async easy

EasonTyler / 2757人閱讀

摘要:有許多理由你將會(huì)需要用到好吧先來解釋一下什么是。這類似于我們經(jīng)常使用的返回的那個(gè)玩意比如想要在對(duì)請(qǐng)求來的數(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.

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

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

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

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

轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/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 評(píng)論0 收藏0
  • JavaScript Promise API

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

    peixn 評(píng)論0 收藏0
  • Koa / Co / Bluebird or Q / Generators / Promises /

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

    xingpingz 評(píng)論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 評(píng)論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ù)劗惓?。我肯定你之前也聽過——異常是個(gè)好東西。一...

    lykops 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<