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

Unified Diff: example/streams/count_clicks.html

Issue 17553018: Initial stream support (Closed) Base URL: https://github.com/dart-lang/fancy-syntax.git@master
Patch Set: Created 7 years, 6 months 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: example/streams/count_clicks.html
diff --git a/example/streams/count_clicks.html b/example/streams/count_clicks.html
new file mode 100644
index 0000000000000000000000000000000000000000..0135897a56145e4ea18a254a4c5c843b64f9b12f
--- /dev/null
+++ b/example/streams/count_clicks.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<!--
+Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+for details. All rights reserved. Use of this source code is governed by a
+BSD-style license that can be found in the LICENSE file.
+-->
+
+<html>
+ <body>
+ <template id="test" bind="{{ mouseDown | count }}" syntax="fancy">
+ Clicks: {{ value }}
+ </template>
+ <script type="application/dart">
+ import 'dart:async';
Jennifer Messerly 2013/06/24 18:30:35 style question, should this be left justified?
justinfagnani 2013/06/25 03:45:36 no idea :) it looks better to me this way.
+ import 'dart:html';
+ import 'package:fancy_syntax/syntax.dart';
+ import 'package:fancy_syntax/async.dart';
+ import 'package:mdv_observe/mdv_observe.dart';
+
+ count(StreamBinding s) {
+ var box = new ObservableBox();
+ box.value = 0;
+ s.stream.listen((e) { box.value++; });
+ return box;
+ }
+
+ main() {
+ var globals = {
+ 'mouseDown': document.onMouseDown,
+ 'count': count,
+ };
+
+ TemplateElement.syntax['fancy'] = new FancySyntax(globals: globals);
+
+ query('#test').model = null;
+ }
+ </script>
+ <script src="packages/browser/dart.js"></script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698