Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: src/tests/site/code/async.dart

Issue 83663005: added front page samples to testing, plus a couple of tweaks to front page and code lab (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: put front page code snippets under testing, minor tweaks, fixed carousel height problem Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/tests/site/code/async.dart
diff --git a/src/tests/site/code/async.dart b/src/tests/site/code/async.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5fb037f5ecc3304680607f0bd8dccd33897ac2da
--- /dev/null
+++ b/src/tests/site/code/async.dart
@@ -0,0 +1,19 @@
+import 'dart:async';
+import 'dart:html';
+
+void main() {
+ // Get a stream of key-press events from an element:
+ querySelector('textarea').onKeyPress
+
+ // Filter the stream, getting a stream of events only for certain key codes:
+ .where((e) => e.keyCode >= 32 && e.keyCode <= 122)
+
+ // Convert those key codes, getting a stream of corresponding characters:
+ .map((e) => new String.fromCharCode(e.charCode))
+
+ // Ask for the first character, getting a Future.
+ .first
+
+ // When the Future completes, print the first character to the console.
+ .then((char) => print('First char=$char'));
+}

Powered by Google App Engine
This is Rietveld 408576698