| OLD | NEW |
| 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 /** A change to an observable instance. */ | 5 /** A change to an observable instance. */ |
| 6 class ChangeEvent { | 6 class ChangeEvent { |
| 7 // TODO(sigmund): capture language issues around enums & create a cannonical | 7 // TODO(sigmund): capture language issues around enums & create a cannonical |
| 8 // Dart enum design. | 8 // Dart enum design. |
| 9 /** Type denoting an in-place update event. */ | 9 /** Type denoting an in-place update event. */ |
| 10 static const UPDATE = 0; | 10 static const UPDATE = 0; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 List<ChangeEvent> events; | 65 List<ChangeEvent> events; |
| 66 | 66 |
| 67 EventSummary(this.target) : events = new List<ChangeEvent>(); | 67 EventSummary(this.target) : events = new List<ChangeEvent>(); |
| 68 | 68 |
| 69 void addEvent(ChangeEvent e) { | 69 void addEvent(ChangeEvent e) { |
| 70 events.add(e); | 70 events.add(e); |
| 71 } | 71 } |
| 72 | 72 |
| 73 /** Notify listeners of [target] and parents of [target] about all changes. */ | 73 /** Notify listeners of [target] and parents of [target] about all changes. */ |
| 74 void notify() { | 74 void notify() { |
| 75 if (!events.isEmpty()) { | 75 if (!events.isEmpty) { |
| 76 for (Observable obj = target; obj != null; obj = obj.parent) { | 76 for (Observable obj = target; obj != null; obj = obj.parent) { |
| 77 for (final listener in obj.listeners) { | 77 for (final listener in obj.listeners) { |
| 78 listener(this); | 78 listener(this); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 /** A listener of change events. */ | 85 /** A listener of change events. */ |
| 86 typedef void ChangeListener(EventSummary events); | 86 typedef void ChangeListener(EventSummary events); |
| OLD | NEW |