OLD | NEW |
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 part of polymer; | 5 part of polymer; |
6 | 6 |
7 /** | 7 /// Invoke [callback] in [wait], unless the job is re-registered, |
8 * Invoke [callback] in [wait], unless the job is re-registered, | 8 /// which resets the timer. For example: |
9 * which resets the timer. For example: | 9 /// |
10 * | 10 /// _myJob = runJob(_myJob, callback, const Duration(milliseconds: 100)); |
11 * _myJob = runJob(_myJob, callback, const Duration(milliseconds: 100)); | 11 /// |
12 * | 12 /// Returns a job handle which can be used to re-register a job. |
13 * Returns a job handle which can be used to re-register a job. | |
14 */ | |
15 // Dart note: renamed to runJob to avoid conflict with instance member "job". | 13 // Dart note: renamed to runJob to avoid conflict with instance member "job". |
16 _Job _runJob(_Job job, void callback(), Duration wait) { | 14 _Job _runJob(_Job job, void callback(), Duration wait) { |
17 if (job != null) { | 15 if (job != null) { |
18 job.stop(); | 16 job.stop(); |
19 } else { | 17 } else { |
20 job = new _Job(); | 18 job = new _Job(); |
21 } | 19 } |
22 job.go(callback, wait); | 20 job.go(callback, wait); |
23 return job; | 21 return job; |
24 } | 22 } |
(...skipping 16 matching lines...) Expand all Loading... |
41 } | 39 } |
42 } | 40 } |
43 | 41 |
44 void complete() { | 42 void complete() { |
45 if (_timer != null) { | 43 if (_timer != null) { |
46 stop(); | 44 stop(); |
47 _callback(); | 45 _callback(); |
48 } | 46 } |
49 } | 47 } |
50 } | 48 } |
OLD | NEW |