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

Side by Side Diff: samples-dev/swarm/swarm_ui_lib/observable/ChangeEvent.dart

Issue 2828603002: Format samples and samples-dev directories. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 part of observable; 5 part of observable;
6 6
7 /** A change to an observable instance. */ 7 /** A change to an observable instance. */
8 class ChangeEvent { 8 class ChangeEvent {
9 // TODO(sigmund): capture language issues around enums & create a cannonical 9 // TODO(sigmund): capture language issues around enums & create a cannonical
10 // Dart enum design. 10 // Dart enum design.
(...skipping 29 matching lines...) Expand all
40 40
41 /** 41 /**
42 * Index of the list operation. Insertions prepend in front of the given 42 * Index of the list operation. Insertions prepend in front of the given
43 * index (insert at 0 means an insertion at the beginning of the list). 43 * index (insert at 0 means an insertion at the beginning of the list).
44 */ 44 */
45 final int index; 45 final int index;
46 46
47 /** Factory constructor for property change events. */ 47 /** Factory constructor for property change events. */
48 ChangeEvent.property( 48 ChangeEvent.property(
49 this.target, this.propertyName, this.newValue, this.oldValue) 49 this.target, this.propertyName, this.newValue, this.oldValue)
50 : type = UPDATE, index = null; 50 : type = UPDATE,
51 index = null;
51 52
52 /** Factory constructor for list change events. */ 53 /** Factory constructor for list change events. */
53 ChangeEvent.list( 54 ChangeEvent.list(
54 this.target, this.type, this.index, this.newValue, this.oldValue) 55 this.target, this.type, this.index, this.newValue, this.oldValue)
55 : propertyName = null; 56 : propertyName = null;
56 57
57 /** Factory constructor for [GLOBAL] change events. */ 58 /** Factory constructor for [GLOBAL] change events. */
58 ChangeEvent.global(this.target) 59 ChangeEvent.global(this.target)
59 : type = GLOBAL, newValue = null, oldValue = null, propertyName = null, inde x = null; 60 : type = GLOBAL,
61 newValue = null,
62 oldValue = null,
63 propertyName = null,
64 index = null;
60 } 65 }
61 66
62 /** A collection of change events on a single observable instance. */ 67 /** A collection of change events on a single observable instance. */
63 class EventSummary { 68 class EventSummary {
64 final Observable target; 69 final Observable target;
65 70
66 // TODO(sigmund): evolve this to track changes per property. 71 // TODO(sigmund): evolve this to track changes per property.
67 List<ChangeEvent> events; 72 List<ChangeEvent> events;
68 73
69 EventSummary(this.target) : events = new List<ChangeEvent>(); 74 EventSummary(this.target) : events = new List<ChangeEvent>();
70 75
71 void addEvent(ChangeEvent e) { 76 void addEvent(ChangeEvent e) {
72 events.add(e); 77 events.add(e);
73 } 78 }
74 79
75 /** Notify listeners of [target] and parents of [target] about all changes. */ 80 /** Notify listeners of [target] and parents of [target] about all changes. */
76 void notify() { 81 void notify() {
77 if (!events.isEmpty) { 82 if (!events.isEmpty) {
78 for (Observable obj = target; obj != null; obj = obj.parent) { 83 for (Observable obj = target; obj != null; obj = obj.parent) {
79 for (final listener in obj.listeners) { 84 for (final listener in obj.listeners) {
80 listener(this); 85 listener(this);
81 } 86 }
82 } 87 }
83 } 88 }
84 } 89 }
85 } 90 }
86 91
87 /** A listener of change events. */ 92 /** A listener of change events. */
88 typedef void ChangeListener(EventSummary events); 93 typedef void ChangeListener(EventSummary events);
OLDNEW
« no previous file with comments | « samples-dev/swarm/swarm_ui_lib/layout/ViewLayout.dart ('k') | samples-dev/swarm/swarm_ui_lib/observable/EventBatch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698