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

Side by Side Diff: pkg/polymer/lib/job.dart

Issue 25740006: port polymer data binding tests (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 polymer.job; 5 library polymer.job;
6 6
7 import 'dart:async' show Timer; 7 import 'dart:async' show Timer;
8 8
9 /** 9 /**
10 * Invoke [callback] in [wait], unless the job is re-registered, 10 * Invoke [callback] in [wait], unless the job is re-registered,
(...skipping 10 matching lines...) Expand all
21 } else { 21 } else {
22 job = new Job(); 22 job = new Job();
23 } 23 }
24 job.go(callback, wait); 24 job.go(callback, wait);
25 return job; 25 return job;
26 } 26 }
27 27
28 // TODO(jmesserly): it isn't clear to me what is supposed to be public API here. 28 // TODO(jmesserly): it isn't clear to me what is supposed to be public API here.
29 // Or what name we should use. "Job" is awfully generic. 29 // Or what name we should use. "Job" is awfully generic.
30 // (The type itself is not exported in Polymer.) 30 // (The type itself is not exported in Polymer.)
31 // Remove this type in favor of Timer?
31 class Job { 32 class Job {
32 Function _callback; 33 Function _callback;
33 Timer _timer; 34 Timer _timer;
34 35
35 void go(void callback(), Duration wait) { 36 void go(void callback(), Duration wait) {
36 this._callback = callback; 37 this._callback = callback;
37 _timer = new Timer(wait, complete); 38 _timer = new Timer(wait, complete);
38 } 39 }
39 40
40 void stop() { 41 void stop() {
41 if (_timer != null) { 42 if (_timer != null) {
42 _timer.cancel(); 43 _timer.cancel();
43 _timer = null; 44 _timer = null;
44 } 45 }
45 } 46 }
46 47
47 void complete() { 48 void complete() {
48 if (_timer != null) { 49 if (_timer != null) {
49 stop(); 50 stop();
50 _callback(); 51 _callback();
51 } 52 }
52 } 53 }
53 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698