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 library action_link_element; | 5 library action_link_element; |
6 | 6 |
| 7 import 'observatory_element.dart'; |
7 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
8 | 9 |
9 @CustomTag('action-link') | 10 @CustomTag('action-link') |
10 class ActionLinkElement extends PolymerElement { | 11 class ActionLinkElement extends ObservatoryElement { |
11 ActionLinkElement.created() : super.created(); | 12 ActionLinkElement.created() : super.created(); |
12 | 13 |
13 @observable bool busy = false; | 14 @observable bool busy = false; |
14 @published var callback = null; | 15 @published var callback = null; |
15 @published String label = 'action'; | 16 @published String label = 'action'; |
16 @published String color = null; | 17 @published String color = null; |
17 | 18 |
18 void doAction(var a, var b, var c) { | 19 void doAction(var a, var b, var c) { |
19 if (busy) { | 20 if (busy) { |
20 return; | 21 return; |
21 } | 22 } |
22 if (callback != null) { | 23 if (callback != null) { |
23 busy = true; | 24 busy = true; |
24 // TODO(turnidge): Track down why adding a dummy argument makes | 25 callback() |
25 // this work but having a no-argument callback doesn't. | 26 .catchError(app.handleException) |
26 callback(null).whenComplete(() { | 27 .whenComplete(() { |
27 busy = false; | 28 busy = false; |
28 }); | 29 }); |
29 } | 30 } |
30 } | 31 } |
31 } | 32 } |
OLD | NEW |