Understanding Deferred.pipe()

后端 未结 3 1826
失恋的感觉
失恋的感觉 2021-02-01 20:44

I\'ve been reading about deferreds and promises in jQuery but I haven\'t used it yet.

I\'ve understood everything very well but the method pipe. I really didn\'t get wha

3条回答
  •  走了就别回头了
    2021-02-01 20:56

    Hiya is this what you are looking for :)

    [nice read] http://www.bennadel.com/blog/2255-Using-jQuery-s-Pipe-Method-To-Change-Deferred-Resolution.htm

    quote

    The pipe() method provides a filter for both the success and failure resolutions (of the AJAX request). If the original resolution is success, the pipe() filter either passes a truly successful response through; or, it changes the resolution, returning a new rejected promise. Then, if the original request was a failure, which would be truly unexpected in our API, the pipe() filter simply passes through a normalized API response structure....

    Stack link with example Understanding jQuery Deferred.pipe() (has jsfiddle in it)

    Understanding Deferred & Promise? please see here http://joseoncode.com/2011/09/26/a-walkthrough-jquery-deferred-and-promise/

    Jquery official API page http://api.jquery.com/deferred.pipe/ (with examples)

    Description: Utility method to filter and/or chain Deferreds.

    The deferred.pipe() method returns a new promise that filters the status and values of a deferred through a function. The doneFilter and failFilter functions filter the original deferred's resolved / rejected status and values. As of jQuery 1.7, the method also accepts a progressFilter function to filter any calls to the original deferred's notify or notifyWith methods.

提交回复
热议问题