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

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

Issue 974313003: Specs: fix typos in style2.md, checkin forgotten builtins.md, add guard feature to runloop.md, rena… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/builtins.md ('k') | sky/specs/runloop.md » ('j') | 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 import 'dart:collection'; 5 import 'dart:collection';
6 import 'dart:async'; 6 import 'dart:async';
7 7
8 class ExceptionAndStackTrace<T> { 8 class ExceptionAndStackTrace<T> {
9 const ExceptionAndStackTrace(this.exception, this.stackTrace); 9 const ExceptionAndStackTrace(this.exception, this.stackTrace);
10 final T exception; 10 final T exception;
(...skipping 13 matching lines...) Expand all
24 24
25 typedef bool Filter<T>(T t); 25 typedef bool Filter<T>(T t);
26 typedef void Handler<T>(T t); 26 typedef void Handler<T>(T t);
27 27
28 class DispatcherController<T> { 28 class DispatcherController<T> {
29 DispatcherController() : dispatcher = new Dispatcher<T>(); 29 DispatcherController() : dispatcher = new Dispatcher<T>();
30 final Dispatcher<T> dispatcher; 30 final Dispatcher<T> dispatcher;
31 void add(T data) => dispatcher._add(data); 31 void add(T data) => dispatcher._add(data);
32 } 32 }
33 33
34 class Pair<A, B> {
35 const Pair(this.a, this.b);
36 final A a;
37 final B b;
38 }
39
40 class Dispatcher<T> { 34 class Dispatcher<T> {
41 List<Pair<Handler, ZoneUnaryCallback>> _listeners; 35 List<Pair<Handler, ZoneUnaryCallback>> _listeners;
42 void listen(Handler<T> handler) { 36 void listen(Handler<T> handler) {
43 // you should not throw out of this handler 37 // you should not throw out of this handler
44 if (_listeners == null) 38 if (_listeners == null)
45 _listeners = new List<Pair<Handler, ZoneUnaryCallback>>(); 39 _listeners = new List<Pair<Handler, ZoneUnaryCallback>>();
46 _listeners.add(new Pair<Handler, ZoneUnaryCallback>(handler, Zone.current.bi ndUnaryCallback(handler))); 40 _listeners.add(new Pair<Handler, ZoneUnaryCallback>(handler, Zone.current.bi ndUnaryCallback(handler)));
47 } 41 }
48 bool unlisten(Handler<T> handler) { 42 bool unlisten(Handler<T> handler) {
49 if (_listeners == null) 43 if (_listeners == null)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 throw exceptions; 183 throw exceptions;
190 return event.result; 184 return event.result;
191 } 185 }
192 186
193 void _dispatchEventLocally(Event event) { 187 void _dispatchEventLocally(Event event) {
194 event._currentTarget = this; 188 event._currentTarget = this;
195 _eventsController.add(event); 189 _eventsController.add(event);
196 } 190 }
197 } 191 }
198 ``` 192 ```
OLDNEW
« no previous file with comments | « sky/specs/builtins.md ('k') | sky/specs/runloop.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698