| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, 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 part of service; |
| 6 |
| 7 abstract class VM extends Observable { |
| 8 IsolateList _isolates; |
| 9 @reflectable IsolateList get isolates => _isolates; |
| 10 |
| 11 void _initOnce() { |
| 12 assert(_isolates == null); |
| 13 _isolates = new IsolateList(this); |
| 14 } |
| 15 |
| 16 VM() { |
| 17 _initOnce(); |
| 18 } |
| 19 |
| 20 /// Get [id] as an [ObservableMap] from the service directly. |
| 21 Future<ObservableMap> getAsMap(String id) { |
| 22 return getString(id).then((response) { |
| 23 try { |
| 24 var map = JSON.decode(response); |
| 25 Logger.root.info('Decoded $id'); |
| 26 return toObservable(map); |
| 27 } catch (e, st) { |
| 28 return toObservable({ |
| 29 'type': 'Error', |
| 30 'id': '', |
| 31 'kind': 'DecodeError', |
| 32 'message': '$e', |
| 33 }); |
| 34 } |
| 35 }).catchError((error) { |
| 36 return toObservable({ |
| 37 'type': 'Error', |
| 38 'id': '', |
| 39 'kind': 'LastResort', |
| 40 'message': '$error' |
| 41 }); |
| 42 }); |
| 43 } |
| 44 |
| 45 /// Get [id] as a [String] from the service directly. See [getAsMap]. |
| 46 Future<String> getString(String id); |
| 47 } |
| OLD | NEW |