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