Extending Promises in ES6

后端 未结 1 1114
太阳男子
太阳男子 2020-12-10 10:37

I am trying to extend Promise:

class PersistedPromise extends Promise { }

Then call the static resolve on the derived class to

相关标签:
1条回答
  • 2020-12-10 11:18

    Is the above no longer operative, or did not make into the spec, or just not implemented by traceur and/or node?

    ES6 promises in the spec support subclassing. That is, you will eventually be able to subclass promises the way you just did. This is by design.

    That said, none of the browsers currently follow that spec correctly in this regard - as far as I know only the ES6-promise shim, Babel (core-js) and RSVP follow ES6 semantics with regards to subclassing correctly. Support in browsers is eventually coming but it's not there yet. Hold tight.

    Here is a list of currently supporting implementations.

    0 讨论(0)
提交回复
热议问题