DataMapView abstract class
abstract class DataMapView extends Object with ChangeNotificationsMixin, ChangeChildNotificationsMixin { final Map<String, dynamic> _fields = new Map(); /** * Returns the value for the given key or null if key is not in the data object. * Because null values are supported, one should use containsKey to * distinguish between an absent key and a null value. */ dynamic operator[](key) => _fields[key] is DataReference ? _fields[key].value : _fields[key]; /** * Returns true if there is no {key, value} pair in the data object. */ bool get isEmpty { return _fields.isEmpty; } /** * Returns true if there is at least one {key, value} pair in the data object. */ bool get isNotEmpty { return _fields.isNotEmpty; } /** * The keys of data object. */ Iterable get keys { return _fields.keys; } /** * The values of [DataMap]. */ Iterable get values { return _fields.values.map((elem) => elem is DataReference ? elem.value : elem); } /** * The number of {key, value} pairs in the [DataMap]. */ int get length { return _fields.length; } /** * Returns whether this data object contains the given [key]. */ bool containsKey(String key) { return _fields.containsKey(key); } bool containsValue(Object value) { if(_fields.containsValue(value)) return true; bool contains = false; _fields.forEach((K, elem) { if(elem is DataReference && elem.value == value) contains = true;}); return contains; } /** * Converts to Map. */ Map toJson() => new Map.fromIterables(this.keys, this.values); /** * Returns Json representation of the object. */ String toString() => toJson().toString(); /** * Should release all allocated (referenced) resources as subscribtions. */ void dispose() { _dispose(); } }
Subclasses
Mixins
ChangeNotificationsMixin, ChangeChildNotificationsMixin
Properties
final bool isEmpty #
Returns true if there is no {key, value} pair in the data object.
bool get isEmpty { return _fields.isEmpty; }
final bool isNotEmpty #
Returns true if there is at least one {key, value} pair in the data object.
bool get isNotEmpty { return _fields.isNotEmpty; }
final int length #
The number of {key, value} pairs in the DataMap.
int get length { return _fields.length; }
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; }
final Stream<Map> onChangeSync #
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;
Operators
dynamic operator [](key) #
Returns the value for the given key or null if key is not in the data object. Because null values are supported, one should use containsKey to distinguish between an absent key and a null value.
dynamic operator[](key) => _fields[key] is DataReference ? _fields[key].value : _fields[key];
Methods
bool containsKey(String key) #
Returns whether this data object contains the given key.
bool containsKey(String key) { return _fields.containsKey(key); }
bool containsValue(Object value) #
bool containsValue(Object value) { if(_fields.containsValue(value)) return true; bool contains = false; _fields.forEach((K, elem) { if(elem is DataReference && elem.value == value) contains = true;}); return contains; }
void dispose() #
Should release all allocated (referenced) resources as subscribtions.
void dispose() { _dispose(); }