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

Unified Diff: runtime/observatory/lib/src/elements/nav/vm_menu.dart

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/nav/vm_menu.dart
diff --git a/runtime/observatory/lib/src/elements/nav/vm_menu.dart b/runtime/observatory/lib/src/elements/nav/vm_menu.dart
index a46d4ca19d2ea4442582ff48964d91ab346ec33c..e4351affe33a2c174068b01fd92749a498122c8e 100644
--- a/runtime/observatory/lib/src/elements/nav/vm_menu.dart
+++ b/runtime/observatory/lib/src/elements/nav/vm_menu.dart
@@ -5,7 +5,7 @@
import 'dart:html';
import 'dart:async';
import 'package:observatory/models.dart' as M
- show VM, IsolateRef, Target, VMUpdateEvent;
+ show VM, EventRepository;
import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
import 'package:observatory/src/elements/helpers/tag.dart';
import 'package:observatory/src/elements/helpers/uris.dart';
@@ -21,28 +21,27 @@ class NavVMMenuElement extends HtmlElement implements Renderable {
Stream<RenderedEvent<NavVMMenuElement>> get onRendered => _r.onRendered;
- Stream<M.VMUpdateEvent> _updates;
- StreamSubscription _updatesSubscription;
-
bool _last;
M.VM _vm;
- M.Target _target;
+ M.EventRepository _events;
+ StreamSubscription _updatesSubscription;
+
+
bool get last => _last;
M.VM get vm => _vm;
- M.Target get target => _target;
+
set last(bool value) => _last = _r.checkAndReact(_last, value);
- factory NavVMMenuElement(M.VM vm, Stream<M.VMUpdateEvent> updates,
- {bool last: false, M.Target target, RenderingQueue queue}) {
+ factory NavVMMenuElement(M.VM vm, M.EventRepository events, {bool last: false,
+ RenderingQueue queue}) {
assert(vm != null);
- assert(updates != null);
+ assert(events != null);
assert(last != null);
NavVMMenuElement e = document.createElement(tag.name);
e._r = new RenderingScheduler(e, queue: queue);
e._vm = vm;
- e._updates = updates;
+ e._events = events;
e._last = last;
- e._target = target;
return e;
}
@@ -51,29 +50,25 @@ class NavVMMenuElement extends HtmlElement implements Renderable {
@override
void attached() {
super.attached();
+ _updatesSubscription = _events.onVMUpdate
+ .listen((e) { _vm = e.vm; _r.dirty(); });
_r.enable();
- _updatesSubscription = _updates
- .listen((M.VMUpdateEvent e) { _vm = e.vm; _r.dirty(); });
}
@override
void detached() {
super.detached();
- _r.disable(notify: true);
shadowRoot.children = [];
- assert(_updatesSubscription != null);
+ _r.disable(notify: true);
_updatesSubscription.cancel();
- _updatesSubscription = null;
}
void render() {
- final String name = (target == null) ? vm.name
- : '${vm.name}@${target.name}';
- /// TODO(cbernaschina) use the isolate repository.
shadowRoot.children = [
- new NavMenuElement(name, link: Uris.vm(), last: last, queue: _r.queue)
+ new NavMenuElement(vm.displayName, link: Uris.vm(), last: last,
+ queue: _r.queue)
..children = (
- _vm.isolates.map((M.IsolateRef isolate) {
+ _vm.isolates.map((isolate) {
return new NavMenuItemElement(isolate.name, queue: _r.queue,
link: Uris.inspect(isolate));
}).toList()

Powered by Google App Engine
This is Rietveld 408576698