Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: runtime/observatory/lib/src/elements/isolate_ref.dart

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted error-ref tag Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 isolate_ref_element; 5 library isolate_ref_element;
6 6
7 import 'package:polymer/polymer.dart'; 7 import 'dart:html';
8 import 'service_ref.dart'; 8 import 'dart:async';
9 import 'package:observatory/repositories.dart'
10 show IsolateRef, IsolateUpdateEvent;
11 import 'package:observatory/src/elements/helpers/tag.dart';
9 12
10 @CustomTag('isolate-ref') 13 class IsolateRefElement extends HtmlElement {
11 class IsolateRefElement extends ServiceRefElement { 14 static const tag = const Tag<IsolateRefElement>('isolate-ref-wrapped');
15
16 Stream<IsolateUpdateEvent> _updates;
17 StreamSubscription _updatesSubscription;
18 IsolateRef _isolate;
19
20 IsolateRef get isolate => _isolate;
21
22 factory IsolateRefElement(IsolateRef isolate,
23 Stream<IsolateUpdateEvent> updates) {
24 assert(isolate != null);
25 assert(updates != null);
26 IsolateRefElement e = document.createElement(tag.name);
27 e._isolate = isolate;
28 e._updates = updates;
29 return e;
30 }
31
12 IsolateRefElement.created() : super.created(); 32 IsolateRefElement.created() : super.created();
33
34 @override
35 void attached() {
36 super.attached();
37 assert(_isolate != null);
38 assert(_updates != null);
39 render();
40 _updatesSubscription = _updates
41 .where((IsolateUpdateEvent e) => e.isolate.id == isolate.id)
42 .listen((IsolateUpdateEvent e) { _isolate = e.isolate; render(); });
43 }
44
45 @override
46 void detached() {
47 super.detached();
48 assert(_updatesSubscription != null);
49 _updatesSubscription.cancel();
50 _updatesSubscription = null;
51 }
52
53 void render() {
54 children = [
55 new AnchorElement(href:
56 '#/inspect?isolateId=${Uri.encodeComponent(isolate.id)}')
57 ..text = 'Isolate ${isolate.number} (${isolate.name})'
58 ..classes = ['isolate-ref']
59 ];
60 }
13 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698