OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/helpers/tag.dart'; | 8 import 'package:observatory/src/elements/helpers/tag.dart'; |
9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
10 import 'package:observatory/src/elements/nav/notify_event.dart'; | 10 import 'package:observatory/src/elements/nav/notify_event.dart'; |
11 import 'package:observatory/src/elements/nav/notify_exception.dart'; | 11 import 'package:observatory/src/elements/nav/notify_exception.dart'; |
12 | 12 |
13 class NavNotifyElement extends HtmlElement implements Renderable { | 13 class NavNotifyElement extends HtmlElement implements Renderable { |
14 static const tag = const Tag<NavNotifyElement>('nav-notify-wrapped', | 14 static const tag = const Tag<NavNotifyElement>('nav-notify', |
15 dependencies: const [ NavNotifyEventElement.tag, | 15 dependencies: const [ NavNotifyEventElement.tag, |
16 NavNotifyExceptionElement.tag ]); | 16 NavNotifyExceptionElement.tag ]); |
17 | 17 |
18 RenderingScheduler _r; | 18 RenderingScheduler _r; |
19 | 19 |
20 Stream<RenderedEvent<NavNotifyElement>> get onRendered => _r.onRendered; | 20 Stream<RenderedEvent<NavNotifyElement>> get onRendered => _r.onRendered; |
21 | 21 |
22 M.NotificationRepository _repository; | 22 M.NotificationRepository _repository; |
23 StreamSubscription _subscription; | 23 StreamSubscription _subscription; |
24 | 24 |
25 bool _notifyOnPause; | 25 bool _notifyOnPause; |
26 | 26 |
27 bool get notifyOnPause => _notifyOnPause; | 27 bool get notifyOnPause => _notifyOnPause; |
28 | 28 |
29 set notifyOnPause(bool value) => | 29 set notifyOnPause(bool value) => |
30 _notifyOnPause = _r.checkAndReact(_notifyOnPause, value); | 30 _notifyOnPause = _r.checkAndReact(_notifyOnPause, value); |
31 | 31 |
32 factory NavNotifyElement(M.NotificationRepository repository, | 32 factory NavNotifyElement(M.NotificationRepository repository, |
33 {bool notifyOnPause: true, RenderingQueue queue}) { | 33 {bool notifyOnPause: true, RenderingQueue queue}) { |
34 assert(repository != null); | 34 assert(repository != null); |
35 assert(notifyOnPause != null); | 35 assert(notifyOnPause != null); |
36 NavNotifyElement e = document.createElement(tag.name); | 36 NavNotifyElement e = document.createElement(tag.name); |
37 e._r = new RenderingScheduler(e, queue: queue); | 37 e._r = new RenderingScheduler(e, queue: queue); |
38 e._repository = repository; | 38 e._repository = repository; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return new NavNotifyExceptionElement( | 83 return new NavNotifyExceptionElement( |
84 notification.exception, stacktrace: notification.stacktrace, | 84 notification.exception, stacktrace: notification.stacktrace, |
85 queue: _r.queue) | 85 queue: _r.queue) |
86 ..onDelete.listen((_) => _repository.delete(notification)); | 86 ..onDelete.listen((_) => _repository.delete(notification)); |
87 } else { | 87 } else { |
88 assert(false); | 88 assert(false); |
89 return new DivElement()..text = 'Invalid Notification Type'; | 89 return new DivElement()..text = 'Invalid Notification Type'; |
90 } | 90 } |
91 } | 91 } |
92 } | 92 } |
OLD | NEW |