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

JS Learn area: async module rewrite #12930

Merged
merged 7 commits into from
Mar 7, 2022

Conversation

wbamberg
Copy link
Collaborator

@wbamberg wbamberg commented Feb 12, 2022

This PR contains a rewrite of the JS async module. It replaces #12525: this PR contains versions of the 2 articles in that PR, plus three new articles that should complete the module.

I'm marking this draft because it should be merged along with the corresponding update to the learning-area repo over in mdn/learning-area#453, and changes in either PR might mean we need changes in the other one. So let's not merge this until mdn/learning-area#453 is approved (and vice versa).

But it should be ready for review.

Before this PR, the module contained the following articles:

  1. General asynchronous programming concepts
  2. Introducing asynchronous JavaScript
  3. Cooperative asynchronous JavaScript: Timeouts and intervals
  4. Handling async operations gracefully with Promises
  5. Making asynchronous programming easier with async and await
  6. Choosing the right approach

For the reasons given in #12525, I thought I'd try rewriting this module and streamlining it. In this PR we have 5 articles:

  1. Introducing asynchronous JavaScript: conceptual introduction to async and why it matters, a bit about events and callbacks, and why they are problematic.
  2. How to use promises: how to work with promise-based APIs: promise chains, error handling, promise.all(), async/await. This is the central article: I think if there's one thing we want beginners to take away, it's how to use promise-based APIs and especially how to write promise chains.
  3. Implementing a promise-based API: quite short article going through creating promises.
  4. Introducing workers: a bit on threads and walk through using a worker.
  5. Assessment: Sequencing animations: a practical exercise to reinforce the lesson about using promises.

I'm hoping that this will be more digestible than what was there before and hope that I haven't jettisoned too much stuff.

Note that the links to example code won't work until mdn/learning-area#453 is merged, but you could see them at the wbamberg equivalent, such as https://wbamberg.github.io/learning-area/javascript/asynchronous/sequencing-animations/finished.

@github-actions github-actions bot added the Content:Learn Learning area docs label Feb 12, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2022

Preview URLs

Flaws

None! 🎉

External URLs

URL: /en-US/docs/Learn/JavaScript/Asynchronous
Title: Asynchronous JavaScript
on GitHub

No new external URLs


URL: /en-US/docs/Learn/JavaScript/Asynchronous/Introducing
Title: Introducing asynchronous JavaScript
on GitHub

No new external URLs


URL: /en-US/docs/Learn/JavaScript/Asynchronous/Introducing_workers
Title: Introducing workers
on GitHub


URL: /en-US/docs/Learn/JavaScript/Asynchronous/Implementing_a_promise-based_API
Title: How to implement a promise-based API
on GitHub

No new external URLs


URL: /en-US/docs/Learn/JavaScript/Asynchronous/Sequencing_animations
Title: Sequencing animations
on GitHub


URL: /en-US/docs/Learn/JavaScript/Asynchronous/Promises
Title: How to use promises
on GitHub

(this comment was updated 2022-03-07 18:01:24.349471)

console.log(`result: ${result3}`);
});
});
});
Copy link
Member

Choose a reason for hiding this comment

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

I am a little concerned that the first use of the arrow function is used in the last example only; if people are confused they may think the arrow function makes it asynchronous. Would it be possible to include an arrow function expression elsewhere, much earlier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there a particular place where you would like to see them? There are lots of arrow functions earlier in this article, and arrow functions are explained earlier in the course and consistently used throughout. I hope that people taking this course, who haven't the disadvantage of having learned JS before arrow functions, will see them as the default, normal way to write anonymous callback functions.

Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

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

This looks good to me! Great to see how it evolved and got even better from the first PR that you had filed for async.

@wbamberg wbamberg marked this pull request as ready for review March 7, 2022 18:01
@wbamberg wbamberg requested review from a team as code owners March 7, 2022 18:01
@wbamberg wbamberg requested review from Rumyra and removed request for a team March 7, 2022 18:01
@wbamberg wbamberg merged commit 7cf00af into mdn:main Mar 7, 2022
wbamberg added a commit to wbamberg/content that referenced this pull request Mar 8, 2022
* upstream/main: (237 commits)
  Fixes anchor to browser compatibility table (mdn#13549)
  Fix incorrect casing of getTitlebarAreaRect (mdn#13631)
  Typo (missing s for plural) (mdn#13609)
  Fix a link (mdn#13621)
  Reduce redirects (mdn#13618)
  Adapt api.Window.onappinstalled to new events structure (mdn#13615)
  Add an example on how to list files from a `FileSystemDirectoryHandle` (mdn#13510)
  Fix a llink in the async Learn module (mdn#13623)
  Undo incorrect fix to justify-items syntax (mdn#13622)
  JS Learn: update client-side APIs, part 2 (mdn#13123)
  JS Learn area: async module rewrite (mdn#12930)
  Fix a link (mdn#13619)
  JS Learn: update client-side APIs, part 1 (mdn#13121)
  Adapt api.SharedWorker.onerror to new events structure (mdn#13599)
  Adapt api.OfflineAudioContext.oncomplete to new events structure (mdn#13568)
  Adapt MediaKeySession API to new events structure (mdn#13527)
  Adapt api.Document.onvisibilitychange to new events structure (mdn#13206)
  Change HTML table to a modern list (AudioProcessingEvent) (mdn#13606)
  Adapt api.Performance.onresourcetimingbufferfull to new events structure (mdn#13603)
  Few changes to outline. (mdn#13414)
  ...
@wbamberg wbamberg deleted the update-js-la-async-rewrite-2 branch April 5, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Learn Learning area docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants