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

Side by Side Diff: samples/third_party/todomvc/web/model.dart

Issue 27618002: package:observe fix various api issues (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 todomvc.web.model; 5 library todomvc.web.model;
6 6
7 import 'package:polymer/polymer.dart'; 7 import 'package:polymer/polymer.dart';
8 8
9 final appModel = new AppModel._(); 9 final appModel = new AppModel._();
10 10
11 @reflectable 11 @reflectable
12 class AppModel extends ObservableBase { 12 class AppModel extends Observable {
13 final ObservableList<Todo> todos = new ObservableList<Todo>(); 13 final ObservableList<Todo> todos = new ObservableList<Todo>();
14 @observable int doneCount; 14 @observable int doneCount;
15 @observable int remaining; 15 @observable int remaining;
16 @observable List<Todo> visibleTodos; 16 @observable List<Todo> visibleTodos;
17 @observable bool hasCompleteTodos; 17 @observable bool hasCompleteTodos;
18 18
19 bool _allChecked; 19 bool _allChecked;
20 20
21 AppModel._() { 21 AppModel._() {
22 new ListPathObserver(todos, 'done').changes.listen(_updateTodoDone); 22 new ListPathObserver(todos, 'done').changes.listen(_updateTodoDone);
(...skipping 29 matching lines...) Expand all
52 52
53 // TODO(jmesserly): the @observable here is temporary. 53 // TODO(jmesserly): the @observable here is temporary.
54 bool get allChecked => _allChecked; 54 bool get allChecked => _allChecked;
55 set allChecked(bool value) { 55 set allChecked(bool value) {
56 todos.forEach((t) { t.done = value; }); 56 todos.forEach((t) { t.done = value; });
57 } 57 }
58 58
59 void clearDone() => todos.removeWhere((t) => t.done); 59 void clearDone() => todos.removeWhere((t) => t.done);
60 } 60 }
61 61
62 class Todo extends ObservableBase { 62 class Todo extends Observable {
63 @observable String task; 63 @observable String task;
64 @observable bool done = false; 64 @observable bool done = false;
65 65
66 Todo(this.task); 66 Todo(this.task);
67 67
68 String toString() => "$task ${done ? '(done)' : '(not done)'}"; 68 String toString() => "$task ${done ? '(done)' : '(not done)'}";
69 } 69 }
OLDNEW
« no previous file with comments | « samples/survey/web/elements/survey/survey_element.dart ('k') | samples/third_party/todomvc/web/todo_row.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698