Chromium Code Reviews| 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> |