Giter Site home page Giter Site logo

es6-promise-always's Introduction

es6-promise-always's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

my-plugin

es6-promise-always's Issues

调用always后无法继续调用then和catch的问题

always没有返回值会导致后续方法无法继续调用,以下是修复代码:

!function (t) {
  if (!t.Promise || t.Promise.prototype.always) return;
  t.Promise.prototype.always = function (callback) {
    return this.then(function (d) {
      return callback(d, undefined) || d;
    }, function (e) {
      callback(undefined, e);
      throw e;
    });
  }
}(typeof window === "undefined" ? global : window);

.then.catch.always

其实。。如果写了一个promise.then.catch.always

always依赖前面then和catch的return值,如果没有return任何值,always中不会接收到任何参数

这里always就等于then啊,也就是:
promise.then.catch.always
promise.then.catch.then
二者等效

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.