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

Unified Diff: runtime/observatory/lib/src/repositories/notification.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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/repositories/notification.dart
diff --git a/runtime/observatory/lib/src/repositories/notification.dart b/runtime/observatory/lib/src/repositories/notification.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2e58b213e7594ef59b86eb46b98396fdd06cc3b8
--- /dev/null
+++ b/runtime/observatory/lib/src/repositories/notification.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file
+
+part of repositories;
+
+class NotificationChangeEvent implements M.NotificationChangeEvent {
+ final NotificationRepository repository;
+ NotificationChangeEvent(this.repository);
+}
+
+class NotificationRepository implements M.NotificationRepository {
+ final List<M.Notification> _list = new List<M.Notification>();
+
+ final StreamController<M.NotificationChangeEvent> _onChange;
+ final Stream<M.NotificationChangeEvent> onChange;
+
+ void add(M.Notification notification) {
+ _list.add(notification);
+ _onChange.add(new NotificationChangeEvent(this));
+ }
+
+ Iterable<M.Notification> list() => _list;
+
+ void delete(M.Notification notification) {
+ if (_list.remove(notification))
+ _onChange.add(new NotificationChangeEvent(this));
+ }
+
+ void deleteAll() {
+ if (_list.isNotEmpty) {
+ _list.clear();
+ _onChange.add(new NotificationChangeEvent(this));
+ }
+ }
+
+ factory NotificationRepository() {
+ var controller = new StreamController<M.NotificationChangeEvent>();
+ var stream = controller.stream.asBroadcastStream();
+ return new NotificationRepository._(controller, stream);
+ }
+ NotificationRepository._(this._onChange, this.onChange);
+}
« no previous file with comments | « runtime/observatory/lib/src/models/repository.dart ('k') | runtime/observatory/lib/src/repositories/script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698