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

async await codelab #1659

Merged
merged 51 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7cf3303
Add WIP async await codelab
legalcodes Jun 4, 2019
cd75e7f
Limit lines to 80 chars
legalcodes Jun 4, 2019
33a671b
Round 1 of revisions:
legalcodes Jun 5, 2019
3934ee6
Add more updates per language comments/suggestions review feedback
legalcodes Jun 5, 2019
b34a5d7
Further small updates addressing review comments.
legalcodes Jun 5, 2019
b587b7f
Configure site.alert templates and update futures codelab w/ templates
legalcodes Jun 6, 2019
7396cc6
Add "Practicing" section iframe; slight restructure for "Errors" section
legalcodes Jun 6, 2019
0e169e0
Added dartpad examples
legalcodes Jun 10, 2019
d2bafa7
Remove extra title
legalcodes Jun 11, 2019
846944c
Remove section head and use of "future object"
legalcodes Jun 11, 2019
60374bf
Remove typos
legalcodes Jun 11, 2019
48f7c3a
Merge branch 'master' of https://github.com/dart-lang/site-www into f…
legalcodes Jun 11, 2019
0fd4ed2
Punctuate all bulleted list items.
legalcodes Jun 12, 2019
4417dd9
Allow check-code to fail for dart dev builds
legalcodes Jun 12, 2019
11427cf
Correct mistaken exclusion of check-code from builds
legalcodes Jun 12, 2019
a63570b
Allow failure for check-code.sh
legalcodes Jun 12, 2019
38b3d5b
Merge branch 'master' of https://github.com/dart-lang/site-www into f…
legalcodes Jun 12, 2019
5f9d525
Allow failure for both check-code and analyze-and-test-examples
legalcodes Jun 12, 2019
c0c98ae
Updates per ux and tw review
legalcodes Jun 19, 2019
5ff8fb1
More updates per review from @sfshaza2
legalcodes Jun 19, 2019
d18e711
Updates per latest sfshaza2 comments
legalcodes Jul 9, 2019
71b621c
Merge branch 'master' of https://github.com/dart-lang/site-www into f…
legalcodes Jul 9, 2019
0c92c5c
Incorporate first part of changes from UX round 2
legalcodes Jul 11, 2019
9d136d3
Merge branch 'master' of https://github.com/dart-lang/site-www into f…
legalcodes Jul 15, 2019
3120d87
Correct typos, turn on latest DartPad UI, and misc small fxies
legalcodes Jul 16, 2019
123f576
Update descriptions for examples
legalcodes Jul 16, 2019
f67ffc4
Add updates from observing test user
legalcodes Jul 18, 2019
5e5ec20
Minor update for example missing a border, extra sentence for DartPad
legalcodes Jul 19, 2019
125f9a3
Re-organize introduction per latest feedback:
legalcodes Jul 20, 2019
4ee31a2
Remove "!" characters from "Putting it all together" section
legalcodes Jul 24, 2019
64dc921
Adding changes from latest review
legalcodes Jul 30, 2019
da8e3e3
Refactored sync / async comparison section into 2 columns
legalcodes Jul 31, 2019
95a7ab7
Updated instructions before each example
legalcodes Jul 31, 2019
c151e1d
Add changes before switching markup back to single-column view
legalcodes Aug 1, 2019
86367c6
Completed markup re-write
legalcodes Aug 2, 2019
d7b72c0
Finished updates from latest review comments
legalcodes Aug 2, 2019
0e6a5a9
End with new lines for .travis.yml and .firebaserc
legalcodes Aug 2, 2019
cc371e2
Remove dartpad includes file, update nav per review comments
legalcodes Aug 2, 2019
60a0d36
Update codelab title
legalcodes Aug 2, 2019
f48f067
Incorporate suggestions from latest review
legalcodes Aug 2, 2019
2c8c32f
Enforce 80 char line limit
legalcodes Aug 2, 2019
9621eb3
Small changes from latest review
legalcodes Aug 5, 2019
e0aa7b8
Updates from latest review
legalcodes Aug 6, 2019
f672a1a
Test omitting refresh-code-excerpts.sh - failing built
legalcodes Aug 6, 2019
b2a44ce
Remove test fix for build
legalcodes Aug 6, 2019
cdda574
Some changes based on recent review
legalcodes Aug 6, 2019
37b6c04
Incorporate latest review items
legalcodes Aug 6, 2019
6624930
Remove 'before running it'
legalcodes Aug 6, 2019
fb19d9c
Exercise applies to "Working with futures"
legalcodes Aug 7, 2019
f48d9c3
More updates - latest review
legalcodes Aug 7, 2019
218c301
Add survey at the end of the codelab
legalcodes Aug 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .firebaserc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"sz" : "sz-www-1",
"sz2" : "sz-www-2"
}
}
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ deploy:

# Only run Travis jobs for named branches (to avoid double builds for each PR)
branches:
only: [master, /^\d\.x$/, /^\d-dev$/, /travis-build/]
only: [master, /^\d\.x$/, /^\d-dev$/, /travis-build/]
2 changes: 0 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ custom:
ext: zip
editor-ext: zip



# Build settings

assets:
Expand Down
6 changes: 3 additions & 3 deletions src/_data/side-nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
- title: Codelabs
expanded: true
children:
- title: Overview
- title: List of Dart codelabs
urlExactMatch: true
match-page-url-exactly: true
permalink: /codelabs
- title: Cheatsheet codelab
- title: Language cheatsheet
permalink: /codelabs/dart-cheatsheet
- title: Asynchronous Programming with Dart
- title: "Asynchrony: futures, async, await"
permalink: /codelabs/async-await
- title: Tutorials
urlExactMatch: true
Expand Down
16 changes: 0 additions & 16 deletions src/_includes/dartpad-exercise-how-to.md

This file was deleted.

260 changes: 143 additions & 117 deletions src/codelabs/async-await/index.md

Large diffs are not rendered by default.

42 changes: 29 additions & 13 deletions src/codelabs/dart-cheatsheet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,23 @@ This codelab — which is based on a
written by and for Google engineers —
walks you through the most important of these language features.

{% include dartpad-exercise-how-to.md %}
The embedded editors in this codelab have partially completed code snippets.
You can use these editors to test your knowledge by completing the code and
clicking the **Run** button.
If you need help, click the **Hint** button.
To run the code formatter ([dartfmt](/tools/dartfmt)), click **Format**.
The **Reset** button erases your work and
restores the editor to its original state.

<aside class="alert alert-warning">
The embedded editors use an experimental version of DartPad.
If you find a DartPad bug or have suggestions for DartPad, please
<a target="_BLANK" href="https://github.com/dart-lang/dart-pad/issues/new">create a DartPad issue.</a>
If you have suggestions for the text or examples in this codelab,
you can create a site issue by clicking the bug icon
at the top right of this page.
</aside>


## String interpolation

Expand Down Expand Up @@ -105,7 +121,7 @@ You can chain multiple uses of `?.` together in a single expression:
myObject?.someProperty?.someMethod()
{% endprettify %}

The preceding code returns null (and never calls `someMethod`) if either
The preceding code returns null (and never calls `someMethod()`) if either
`myObject` or `myObject.someProperty` is
null.

Expand Down Expand Up @@ -165,7 +181,7 @@ This arrow syntax is a way to define a function that executes the
expression to its right and returns its value.

For example, consider this call to the `List` class's
`any` method:
`any()` method:

{% prettify dart %}
bool hasEmpty = aListOfStrings.any((s) {
Expand Down Expand Up @@ -203,16 +219,16 @@ We've all seen an expression like this:
myObject.someMethod()
{% endprettify %}

It invokes `someMethod` on `myObject`, and the result of
the expression is the return value of `someMethod`.
It invokes `someMethod()` on `myObject`, and the result of
the expression is the return value of `someMethod()`.

Here's the same expression with a cascade:

{% prettify dart %}
myObject..someMethod()
{% endprettify %}

Although it still invokes `someMethod` on `myObject`, the result
Although it still invokes `someMethod()` on `myObject`, the result
of the expression **isn't** the return value — it's a reference to `myObject`!
Using cascades, you can chain together operations that
would otherwise require separate statements.
Expand Down Expand Up @@ -342,7 +358,7 @@ print(newTotal); // <-- prints 15

### Code example

Implement a function called `joinWithCommas` that accepts one to
Implement a function called `joinWithCommas()` that accepts one to
five integers, then returns a string of those numbers separated by commas.
Here are some examples of function calls and returned values:

Expand Down Expand Up @@ -385,14 +401,14 @@ A function can't have both optional positional and optional named parameters.

### Code example

Add a `copyWith` instance method to the `MyDataObject`
Add a `copyWith()` instance method to the `MyDataObject`
class. It should take three named parameters:

* `int newInt`
* `String newString`
* `double newDouble`

When called, `copyWith` should return a new `MyDataObject`
When called, `copyWith()` should return a new `MyDataObject`
based on the current instance,
with data from the preceding parameters (if any)
copied into the object's properties.
Expand Down Expand Up @@ -465,16 +481,16 @@ try {

### Code example

Implement `tryFunction` below. It should execute an untrustworthy method and
Implement `tryFunction()` below. It should execute an untrustworthy method and
then do the following:

* If `untrustworthy` throws an `ExceptionWithMessage`,
* If `untrustworthy()` throws an `ExceptionWithMessage`,
call `logger.logException` with the exception type and message
(try using `on` and `catch`).
* If `untrustworthy` throws an `Exception`,
* If `untrustworthy()` throws an `Exception`,
call `logger.logException` with the exception type
(try using `on` for this one).
* If `untrustworthy` throws any other object, don't catch the exception.
* If `untrustworthy()` throws any other object, don't catch the exception.
* After everything's caught and handled, call `logger.doneLogging`
(try using `finally`).

Expand Down
9 changes: 4 additions & 5 deletions src/codelabs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ Use the latest, experimental version of DartPad to learn,
remind yourself about, or test your knowledge of
some of the most commonly used, yet unique features of the Dart language.

### [Futures Async & Await](/codelabs/async-await)
### [Asynchrony: futures, async, await](/codelabs/async-await)

Use DartPad to learn how to write asynchronous code in Dart via futures and the
async/await keywords.
Use the latest, experimental version of DartPad to learn how to write
asynchronous code using futures and the `async` and `await` keywords.

## Flutter

To learn about Flutter, try one of the
[Flutter codelabs.]({{site.flutter}}/codelabs)

[Flutter codelabs.]({{site.flutter}}/codelabs)