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 inbound_reference_element; | 5 library inbound_reference_element; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
9 import 'package:observatory/service.dart'; | 9 import 'package:observatory/service.dart'; |
10 import 'service_ref.dart'; | 10 import 'service_ref.dart'; |
11 | 11 |
12 @CustomTag('inbound-reference') | 12 @CustomTag('inbound-reference') |
13 class InboundReferenceElement extends ServiceRefElement { | 13 class InboundReferenceElement extends ServiceRefElement { |
14 @published ObservableMap ref; | |
Cutch
2014/08/28 14:46:05
ServiceMap
rmacnak
2014/08/28 19:41:05
We don't get a ServiceMap here for some reason.
| |
14 InboundReferenceElement.created() : super.created(); | 15 InboundReferenceElement.created() : super.created(); |
15 | 16 |
16 dynamic get slot => ref['slot']; | 17 dynamic get slot => ref['slot']; |
17 bool get slotIsArrayIndex => slot is num; | 18 bool get slotIsArrayIndex => slot is num; |
18 bool get slotIsField => slot is ServiceMap && slot['type'] == '@Field'; | 19 bool get slotIsField => slot is ServiceMap && slot['type'] == '@Field'; |
19 | 20 |
20 ServiceObject get source => ref['source']; | 21 ServiceObject get source => ref['source']; |
21 | 22 |
22 // I.e., inbound references to 'source' for recursive pointer chasing. | 23 // I.e., inbound references to 'source' for recursive pointer chasing. |
23 @observable ObservableList inboundReferences; | 24 @observable ObservableList inboundReferences; |
24 Future<ServiceObject> fetchInboundReferences(arg) { | 25 Future<ServiceObject> fetchInboundReferences(arg) { |
25 return source.isolate.get(source.id + "/inbound_references?limit=$arg") | 26 return source.isolate.get(source.id + "/inbound_references?limit=$arg") |
26 .then((ServiceMap response) { | 27 .then((ServiceMap response) { |
27 inboundReferences = new ObservableList.from(response['references']); | 28 inboundReferences = new ObservableList.from(response['references']); |
28 }); | 29 }); |
29 } | 30 } |
30 | 31 |
31 // TODO(turnidge): This is here to workaround vm/dart2js differences. | 32 // TODO(turnidge): This is here to workaround vm/dart2js differences. |
32 dynamic expander() { | 33 dynamic expander() { |
33 return expandEvent; | 34 return expandEvent; |
34 } | 35 } |
35 | 36 |
36 void expandEvent(bool expand, var done) { | 37 void expandEvent(bool expand, var done) { |
37 assert(ref is ServiceMap); | 38 assert(ref is ServiceMap); |
38 if (expand) { | 39 if (expand) { |
39 fetchInboundReferences(100).then((result) { | 40 fetchInboundReferences(100).then((result) { |
40 notifyPropertyChange(#ref, 0, 1); | 41 notifyPropertyChange(#ref, 0, 1); |
41 }).whenComplete(done); | 42 }).whenComplete(done); |
42 } else { | 43 } else { |
43 ServiceMap refMap = ref; | 44 inboundReferences = null; |
44 refMap['fields'] = null; | |
45 refMap['elements'] = null; | |
46 done(); | 45 done(); |
47 } | 46 } |
48 } | 47 } |
49 } | 48 } |
OLD | NEW |