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