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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more helpful technique for accessing promise #1124

Merged
merged 3 commits into from Sep 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion live-examples/js-examples/promise/promise-constructor.html
@@ -1,9 +1,17 @@
<pre>
<code id="static-js">var promise1 = new Promise(function(resolve, reject) {
setTimeout(resolve, 100, 'foo');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using setTimeout like this, with a 3rd argument ('foo') - is IMHO rather rare.

setTimeout(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's weird to mix arrow functions and non-arrow functions, is there a reason you're doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if I need to do any other changes. Thanks for your time.

resolve('foo');
}, 300);
});

promise1.then(function(value) {
console.log(value);
// expected output: "foo"
});

console.log(promise1);
// expected output: [object Promise]

</code>
</pre>