Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trans impl #7

Open
wants to merge 2 commits into
base: source
Choose a base branch
from
Open

Trans impl #7

wants to merge 2 commits into from

Conversation

chengcyber
Copy link

translate implementation to zh-CN


##[done] Observing (via .done)
##[done] 观测 (通过 .done)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中文语序是不是要反过来: (通过 .done) 观测

We now have a completed state machine, but we still have no way to observe any changes to it.
Our ultimate goal is to implement `.then`, but the semantics of `.done` are much
simpler so lets implement that first.
现在,我们有了一个完整的内部状态机,但是我们还没有任何方法能够观测到它的变化。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好像没提到 内部
感觉可以精简一点: 但是我们还 没有任何方法能够 观测到它的变化。 > 但是我们还 无法 观测到它的变化。

simpler so lets implement that first.
现在,我们有了一个完整的内部状态机,但是我们还没有任何方法能够观测到它的变化。
我们的终极目标是实现 `.then` 方法,不过语义上来说, `.done` 方法看上去容易实现,
我们就现在实现它吧。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

语病?


:js
var PENDING = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:js


##[then] Observing (via .then)
##[then] 观测 (通过 .then)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上的语序问题? 🤔

@@ -326,14 +315,14 @@ just do the same thing, but construct a new Promise in the process.
});
}

##[apendix] Further Reading
##[apendix] 更多阅读

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

扩展阅读?

- [kriskowal/q](https://github.com/kriskowal/q/blob/v1/design/README.md) is a very different implementation of promises and comes with a very nice walkthrough of the design principals behind it.
- [petkaantonov/bluebird](https://github.com/petkaantonov/bluebird) is a promise implementation that was designed exclusively for performance (along with its own esoteric helper methods). The [Optimization Killers](https://github.com/petkaantonov/bluebird/wiki/Optimization-killers) Wiki page is extremely useful for picking up tips.
- [Stack Overflow](http://stackoverflow.com/questions/23772801/basic-javascript-promise-implementation-attempt/23785244#23785244) is the original source of this article.
- [then/promise](https://github.com/then/promise/blob/master/src/core.js) 简单的实现一个 promise 对象

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

意思应该是 用相似的方法实现 promise ?

We now have the completed internal state machine, but we have yet to expose either
a method of resolving the promise or of observing it. Lets start by adding a way
of resolving the promise.
现在,我们已经完成了内部的状态机,但是我们还没有执行处理函数,让我们开始处理 promise 。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原文提到了 observing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants