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

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 vm-connect 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/models.dart' as M
10 show IsolateRef, IsolateUpdateEvent;
11 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
9 13
10 @CustomTag('isolate-ref') 14 class IsolateRefElement extends HtmlElement implements Renderable {
11 class IsolateRefElement extends ServiceRefElement { 15 static const tag = const Tag<IsolateRefElement>('isolate-ref-wrapped');
16
17 RenderingScheduler<IsolateRefElement> _r;
18
19 Stream<RenderedEvent<IsolateRefElement>> get onRendered => _r.onRendered;
20
21 Stream<M.IsolateUpdateEvent> _updates;
22 StreamSubscription _updatesSubscription;
23 M.IsolateRef _isolate;
24
25 M.IsolateRef get isolate => _isolate;
26
27 factory IsolateRefElement(M.IsolateRef isolate,
28 Stream<M.IsolateUpdateEvent> updates, {RenderingQueue queue}) {
29 assert(isolate != null);
30 assert(updates != null);
31 IsolateRefElement e = document.createElement(tag.name);
32 e._r = new RenderingScheduler(e, queue: queue);
33 e._isolate = isolate;
34 e._updates = updates;
35 return e;
36 }
37
12 IsolateRefElement.created() : super.created(); 38 IsolateRefElement.created() : super.created();
39
40 @override
41 void attached() {
42 super.attached();
43 assert(_isolate != null);
44 assert(_updates != null);
45 _r.enable();
46 _updatesSubscription = _updates
47 .where((M.IsolateUpdateEvent e) => e.isolate.id == isolate.id)
48 .listen((M.IsolateUpdateEvent e) { _isolate = e.isolate; _r.dirty(); });
49 }
50
51 @override
52 void detached() {
53 super.detached(); _r.disable(notify: true);
54 children = [];
55 assert(_updatesSubscription != null);
56 _updatesSubscription.cancel();
57 _updatesSubscription = null;
58 }
59
60 void render() {
61 children = [
62 new AnchorElement(href:
63 '#/inspect?isolateId=${Uri.encodeComponent(isolate.id)}')
64 ..text = 'Isolate ${isolate.number} (${isolate.name})'
65 ..classes = ['isolate-ref']
66 ];
67 }
13 } 68 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/isolate_reconnect.html ('k') | runtime/observatory/lib/src/elements/isolate_ref.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698