-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move more details on events from asychrony to capturing-events * shuffle explanation into re-rendering * add first pass of file protocol explanation into using-fetch * tidy the explanation * Update common-content/en/module/js3/re-rendering/index.md Co-authored-by: Daniel Wagner-Hall <[email protected]> * Update common-content/en/module/js3/using-fetch/index.md Co-authored-by: Daniel Wagner-Hall <[email protected]> * Update common-content/en/module/js3/using-fetch/index.md Co-authored-by: Daniel Wagner-Hall <[email protected]> * rename async block * tweak the text * rm a learning objective * simplify copy with hemmingway * rename blocks * Update common-content/en/module/js3/capturing-events/index.md Co-authored-by: Daniel Wagner-Hall <[email protected]> * Update common-content/en/module/js3/synchronous-execution/index.md Co-authored-by: Daniel Wagner-Hall <[email protected]> --------- Co-authored-by: Dedekind561 <[email protected]> Co-authored-by: Daniel Wagner-Hall <[email protected]>
- Loading branch information
1 parent
162acc7
commit ad31478
Showing
6 changed files
with
122 additions
and
128 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
common-content/en/module/js3/synchronous-execution/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
+++ | ||
title = 'Synchronous execution' | ||
|
||
time = 10 | ||
emoji= '⏳' | ||
[objectives] | ||
1="Define asynchrony" | ||
2="Explain how synchronous execution works" | ||
[build] | ||
render = 'never' | ||
list = 'local' | ||
publishResources = false | ||
+++ | ||
|
||
We can handle latency using {{<tooltip title="asynchronous execution">}}Asynchronous execution is running code in a different order than it was written.{{</tooltip>}} To understand asynchrony we first need to be clear about {{<tooltip title="synchronous execution">}}Synchronous execution is running code in the order it is written.{{</tooltip>}}. | ||
|
||
We have written a lot of JavaScript programs that execute sequentially. This means that each line of code is run in order, one after the other. | ||
{{<columns>}} | ||
|
||
#### For example: | ||
|
||
```js | ||
console.log("first"); | ||
console.log("second"); | ||
console.log("third"); | ||
``` | ||
|
||
<---> | ||
|
||
#### Outputs: | ||
|
||
```console | ||
first | ||
second | ||
third | ||
``` | ||
|
||
{{</columns>}} | ||
Each line of code is run in order. This is synchronous execution. We do this because JavaScript is {{<tooltip title="single threaded">}} | ||
A single thread can do one thing at a time. JavaScript is a single threaded language. | ||
{{</tooltip>}}. | ||
|
||
When we call a function, the function will run to completion before the next line of code is executed. But what if we need to wait for something to happen? What if we need to wait for our data to arrive before we can show it? In this case, we can use **asynchronous execution**. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters