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

Side by Side Diff: sky/specs/events.md

Issue 923023005: Specs: Make appendChild, prependChild, and setChild return the child; make Dispatcher's unlisten() … (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 | « sky/specs/elements.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Sky Event Model 1 Sky Event Model
2 =============== 2 ===============
3 3
4 ```dart 4 ```dart
5 SKY MODULE 5 SKY MODULE
6 <!-- part of dart:sky --> 6 <!-- part of dart:sky -->
7 7
8 <script> 8 <script>
9 import 'dart:collection'; 9 import 'dart:collection';
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (_listeners == null) 48 if (_listeners == null)
49 _listeners = new List<Pair<Handler, ZoneUnaryCallback>>(); 49 _listeners = new List<Pair<Handler, ZoneUnaryCallback>>();
50 _listeners.add(new Pair<Handler, ZoneUnaryCallback>(handler, Zone.current.bi ndUnaryCallback(handler))); 50 _listeners.add(new Pair<Handler, ZoneUnaryCallback>(handler, Zone.current.bi ndUnaryCallback(handler)));
51 } 51 }
52 bool unlisten(Handler<T> handler) { 52 bool unlisten(Handler<T> handler) {
53 if (_listeners == null) 53 if (_listeners == null)
54 return false; 54 return false;
55 var target = _listeners.lastWhere((v) => v.a == handler, orElse: () => null) ; 55 var target = _listeners.lastWhere((v) => v.a == handler, orElse: () => null) ;
56 if (target == null) 56 if (target == null)
57 return false; 57 return false;
58 _listeners.remove(target); 58 _listeners.removeAt(_listeners.lastIndexOf(target));
59 return true; 59 return true;
60 } 60 }
61 void _add(T data) { 61 void _add(T data) {
62 if (_listeners == null) 62 if (_listeners == null)
63 return; 63 return;
64 ExceptionListException exceptions = new ExceptionListException(); 64 ExceptionListException exceptions = new ExceptionListException();
65 // we make a copy of the list here so that the listeners can 65 // we make a copy of the list here so that the listeners can
66 // mutate our list without worry 66 // mutate our list without worry
67 _listeners.toList().forEach((Pair<Handler, ZoneUnaryCallback> item) { 67 _listeners.toList().forEach((Pair<Handler, ZoneUnaryCallback> item) {
68 try { 68 try {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return event.result; 179 return event.result;
180 } 180 }
181 181
182 void _dispatchEventLocally(Event event) { 182 void _dispatchEventLocally(Event event) {
183 event._currentTarget = this; 183 event._currentTarget = this;
184 _eventsController.add(event); 184 _eventsController.add(event);
185 } 185 }
186 } 186 }
187 </script> 187 </script>
188 ``` 188 ```
OLDNEW
« no previous file with comments | « sky/specs/elements.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698