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 eval_link_element; | 5 library eval_link_element; |
6 | 6 |
7 import 'package:observatory/service.dart'; | 7 import 'package:observatory/service.dart'; |
8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
9 | 9 |
10 @CustomTag('eval-link') | 10 @CustomTag('eval-link') |
11 class EvalLinkElement extends PolymerElement { | 11 class EvalLinkElement extends PolymerElement { |
12 EvalLinkElement.created() : super.created(); | 12 EvalLinkElement.created() : super.created(); |
13 | 13 |
14 @observable bool busy = false; | 14 @observable bool busy = false; |
| 15 @published String label = "[evaluate]"; |
15 @published var callback = null; | 16 @published var callback = null; |
16 @published String expr = ''; | 17 @published var expr = ''; |
17 @published ServiceObject result = null; | 18 @published ServiceObject result = null; |
18 | 19 |
19 void evalNow(var a, var b, var c) { | 20 void evalNow(var a, var b, var c) { |
20 if (busy) { | 21 if (busy) { |
21 return; | 22 return; |
22 } | 23 } |
23 if (callback != null) { | 24 if (callback != null) { |
24 busy = true; | 25 busy = true; |
25 result = null; | 26 result = null; |
26 callback(expr).then((ServiceObject obj) { | 27 callback(expr).then((ServiceObject obj) { |
27 result = obj; | 28 result = obj; |
28 }).whenComplete(() { | 29 }).whenComplete(() { |
29 busy = false; | 30 busy = false; |
30 }); | 31 }); |
31 } | 32 } |
32 } | 33 } |
33 } | 34 } |
OLD | NEW |