ChangeNotificationsMixin abstract class
abstract class ChangeNotificationsMixin { /** * Controlls notification streams. Used to propagate change events to the outside world. */ StreamController<dynamic> _onChangeController; StreamController<Map> _onChangeSyncController = new StreamController.broadcast(sync: true); /** * [_change] and [_changeSync] are either of a type Change or ChangeSet depending * on concrete implementation of a mixin */ get _change; get _changeSync; /** * following wanna-be-abstract methods must be overriden */ void _clearChanges(); void _clearChangesSync(); void _onBeforeNotify() {} /** * Used to propagate change events to the outside world. */ StreamController<dynamic> _onBeforeAddedController; StreamController<dynamic> _onBeforeRemovedController; /** * Stream populated with [DataMapView] events before any * data object is added. */ Stream<dynamic> get onBeforeAdd { if(_onBeforeAddedController == null) { _onBeforeAddedController = new StreamController.broadcast(sync: true); } return _onBeforeAddedController.stream; } /** * Stream populated with [DataMapView] events before any * data object is removed. */ Stream<dynamic> get onBeforeRemove { if(_onBeforeRemovedController == null) { _onBeforeRemovedController = new StreamController.broadcast(sync: true); } return _onBeforeRemovedController.stream; } /** * Stream populated with [ChangeSet] events whenever the collection or any * of data object contained gets changed. */ Stream<ChangeSet> get onChange { if(_onChangeController == null) { _onChangeController = new StreamController.broadcast(); } return _onChangeController.stream; } /** * Stream populated with {'change': [ChangeSet], 'author': [dynamic]} events * synchronously at the moment when the collection or any data object contained * gets changed. */ Stream<Map> get onChangeSync => _onChangeSyncController.stream; /** * Streams all new changes marked in [_change]. */ void _notify({author: null}) { if (_changeSync != null) { _onChangeSyncController.add({'author': author, 'change': _changeSync}); _clearChangesSync(); } Timer.run(() { if (_change != null) { _onBeforeNotify(); if(_onChangeController != null) _onChangeController.add(_change); _clearChanges(); } }); } void _closeChangeStreams(){ if(_onChangeController != null) _onChangeController.close(); _onChangeSyncController.close(); } }
Subclasses
ChangeChildNotificationsMixin, ChangeValueNotificationsMixin, TransformedDataBase
Properties
final Stream<dynamic> onBeforeAdd #
Stream populated with DataMapView events before any data object is added.
Stream<dynamic> get onBeforeAdd { if(_onBeforeAddedController == null) { _onBeforeAddedController = new StreamController.broadcast(sync: true); } return _onBeforeAddedController.stream; }
final Stream<dynamic> onBeforeRemove #
Stream populated with DataMapView events before any data object is removed.
Stream<dynamic> get onBeforeRemove { if(_onBeforeRemovedController == null) { _onBeforeRemovedController = new StreamController.broadcast(sync: true); } return _onBeforeRemovedController.stream; }
final Stream<ChangeSet> onChange #
Stream populated with ChangeSet events whenever the collection or any of data object contained gets changed.
Stream<ChangeSet> get onChange { if(_onChangeController == null) { _onChangeController = new StreamController.broadcast(); } return _onChangeController.stream; }