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

Side by Side Diff: runtime/observatory/lib/src/elements/isolate_ref_wrapper.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
(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 import 'dart:html';
6 import 'dart:async';
7 import 'package:observatory/repositories.dart' show IsolateUpdateEvent;
8 import 'package:observatory/service_html.dart' show Isolate;
9 import 'package:observatory/src/elements/isolate_ref.dart';
10 import 'package:observatory/src/elements/helpers/tag.dart';
11 import 'package:observatory/src/elements/shims/binding.dart';
12
13 class IsolateRefElementWrapper extends HtmlElement {
14
15 static final binder = new Binder<IsolateRefElementWrapper>(
16 const [const Binding('ref')]);
17
18 static const tag = const Tag<IsolateRefElementWrapper>('isolate-ref');
19
20 final StreamController<IsolateUpdateEvent> _updatesController =
21 new StreamController<IsolateUpdateEvent>();
22 Stream<IsolateUpdateEvent> _updates;
23 StreamSubscription _subscription;
24
25 Isolate _isolate;
26 Isolate get ref => _isolate;
27 void set ref(Isolate ref) { _isolate = ref; _detached(); _attached(); }
28
29 IsolateRefElementWrapper.created() : super.created() {
30 _updates = _updatesController.stream.asBroadcastStream();
31 binder.registerCallback(this);
32 createShadowRoot();
33 render();
34 }
35
36 @override
37 void attached() {
38 super.attached();
39 _attached();
40 }
41
42 void _attached() {
43 if (ref != null) {
44 _subscription = ref.changes.listen((_) {
45 _updatesController.add(new IsolateUpdateEvent(ref));
46 });
47 }
48 render();
49 }
50
51 @override
52 void detached() {
53 super.detached();
54 _detached();
55 }
56
57 void _detached() {
58 if (_subscription != null) {
59 _subscription.cancel();
60 _subscription = null;
61 }
62 }
63
64 void render() {
65 shadowRoot.children = [];
66 if (ref == null) return;
67
68 shadowRoot.children = [
69 new StyleElement()
70 ..text = '@import "packages/observatory/src/elements/css/shared.css";',
71 new IsolateRefElement(_isolate, _updates)
72 ];
73 }
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698