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

Side by Side Diff: runtime/observatory/lib/src/repositories/notification.dart

Issue 2167053002: Converted Observatory nav-notify element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added tests 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) 2016, 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 part of repositories;
6
7 class NotificationChangeEvent implements M.NotificationChangeEvent {
8 final NotificationRepository repository;
9 NotificationChangeEvent(this.repository);
10 }
11
12 class NotificationRepository implements M.NotificationRepository {
13 final List<M.Notification> _list = new List<M.Notification>();
14
15 final StreamController<M.NotificationChangeEvent> _onChange =
16 new StreamController<M.NotificationChangeEvent>.broadcast();
17 Stream<M.NotificationChangeEvent> get onChange => _onChange.stream;
18
19 void add(M.Notification notification) {
20 _list.add(notification);
21 _notify();
22 }
23
24 Iterable<M.Notification> list() => _list;
25
26 void delete(M.Notification notification) {
27 if (_list.remove(notification))
28 _notify();
29 }
30
31 void deleteAll() {
32 if (_list.isNotEmpty) {
33 _list.clear();
34 _notify();
35 }
36 }
37
38 NotificationRepository();
39
40 void _notify() {
41 _onChange.add(new NotificationChangeEvent(this));
42 }
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698