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

Side by Side Diff: example/todomvc/main.dart

Issue 12096106: work in progress: observable implementation using detailed change records (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 10 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 unified diff | Download patch
« no previous file with comments | « bin/build_observable.dart ('k') | example/todomvc/model.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library main; 5 library main;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'model.dart'; 8 import 'model.dart';
9 import 'package:web_ui/web_ui.dart'; 9 import 'package:web_ui/web_ui.dart';
10 10
11 main() { 11 main() {
12 useObservers = true;
13
12 // listen on changes to #hash in the URL 14 // listen on changes to #hash in the URL
13 // Note: listen on both popState and hashChange, because IE9 doens't support 15 // Note: listen on both popState and hashChange, because IE9 doens't support
14 // history API, and it doesn't work properly on Opera 12. 16 // history API, and it doesn't work properly on Opera 12.
15 // See http://dartbug.com/5483 17 // See http://dartbug.com/5483
16 updateFilters(e) { 18 updateFilters(e) {
17 viewModel.showIncomplete = window.location.hash != '#/completed'; 19 viewModel.showIncomplete = window.location.hash != '#/completed';
18 viewModel.showDone = window.location.hash != '#/active'; 20 viewModel.showDone = window.location.hash != '#/active';
19 dispatch(); 21 dispatch();
20 } 22 }
21 window.onHashChange.listen(updateFilters); 23 window.onHashChange.listen(updateFilters);
22 window.onPopState.listen(updateFilters); 24 window.onPopState.listen(updateFilters);
23 } 25 }
24 26
25 void addTodo(Event e) { 27 void addTodo(Event e) {
26 e.preventDefault(); // don't submit the form 28 e.preventDefault(); // don't submit the form
27 var input = query('#new-todo'); 29 var input = query('#new-todo');
28 if (input.value == '') return; 30 if (input.value == '') return;
29 app.todos.add(new Todo(input.value)); 31 app.todos.add(new Todo(input.value));
30 input.value = ''; 32 input.value = '';
31 } 33 }
OLDNEW
« no previous file with comments | « bin/build_observable.dart ('k') | example/todomvc/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698