diff --git a/CHANGELOG.md b/CHANGELOG.md index e73ba789..0d37ee21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.3.2 +- dartfmt style fixes + ## 0.3.1 - WireListener has first parameter Wire that holds signal, scope, listener itself and replies diff --git a/lib/src/data.dart b/lib/src/data.dart index 08dd0fad..caca1e5b 100644 --- a/lib/src/data.dart +++ b/lib/src/data.dart @@ -7,8 +7,7 @@ part of wire; /// typedef WireDataListener = void Function(dynamic value); -class WireData -{ +class WireData { Function _onRemove; final _listeners = >{}; @@ -31,8 +30,8 @@ class WireData WireData(this._key, this._onRemove); void refresh() { - _listeners.forEach((scope, listeners) => - listeners.forEach((func) => func(_value))); + _listeners.forEach( + (scope, listeners) => listeners.forEach((func) => func(_value))); } void remove() { @@ -40,11 +39,12 @@ class WireData _onRemove = null; _key = null; - value = null; // null value means remove element that listening on change (unsubscribe) + // null value means remove element that listening on change (unsubscribe) + value = null; - while(_listeners.isNotEmpty) { + while (_listeners.isNotEmpty) { var value = _listeners.remove(_listeners.keys.last); - while(value.isNotEmpty) { + while (value.isNotEmpty) { value.removeLast(); } } @@ -66,4 +66,4 @@ class WireData } return this; } -} \ No newline at end of file +} diff --git a/lib/src/layer.dart b/lib/src/layer.dart index 659a7b48..f2c22f32 100644 --- a/lib/src/layer.dart +++ b/lib/src/layer.dart @@ -5,13 +5,11 @@ part of wire; /// Github: https://github.com/DQvsRA /// License: APACHE LICENSE, VERSION 2.0 /// -class WireLayer -{ +class WireLayer { final Map _wireByHash = {}; final Map> _hashesBySignal = >{}; - Wire add(Wire wire) - { + Wire add(Wire wire) { var hash = wire.hash; var signal = wire.signal; @@ -26,12 +24,10 @@ class WireLayer return wire; } - bool send(String signal, [data]) - { + bool send(String signal, [data]) { var noSubscribers = true; - if (_hashesBySignal.containsKey(signal)) - { + if (_hashesBySignal.containsKey(signal)) { var WiresToRemove = []; _hashesBySignal[signal].forEach((hash) { var wire = _wireByHash[hash]; @@ -46,8 +42,7 @@ class WireLayer return noSubscribers; } - bool remove(String signal, [Object scope, Function listener]) - { + bool remove(String signal, [Object scope, Function listener]) { var exists = _hashesBySignal.containsKey(signal); if (exists) { var toRemove = []; @@ -66,11 +61,10 @@ class WireLayer /// /// Exclude a Wire based on an signal. /// - /// @param The Wire to remove. + /// @param The Wire to remove. /// @return If there is no hashes (no Wires) for that SIGNAL stop future perform /// - bool _removeSignal(Wire wire) - { + bool _removeSignal(Wire wire) { var hash = wire.hash; var signal = wire.signal; diff --git a/lib/src/main.dart b/lib/src/main.dart index 5d44bb50..37476e94 100644 --- a/lib/src/main.dart +++ b/lib/src/main.dart @@ -60,8 +60,7 @@ class Wire /// int replies = 0; - Wire(Object scope, String signal, WireListener listener, int replies) - { + Wire(Object scope, String signal, WireListener listener, int replies) { _scope = scope; _signal = signal; _listener = listener; @@ -74,8 +73,7 @@ class Wire /// Public Methods /// ///********************************************************************************************************** - void transfer(data) - { + void transfer(data) { // Call a listener in this Wire. _listener(this, data); } @@ -85,17 +83,20 @@ class Wire /// Public Static Methods - API /// ///********************************************************************************************************** - static Wire add(Object scope, String signal, WireListener listener, {int replies = 0}) - { return _LAYER.add(Wire(scope, signal, listener, replies)); } + static Wire add(Object scope, String signal, WireListener listener, + {int replies = 0}) { + return _LAYER.add(Wire(scope, signal, listener, replies)); + } - static bool send(String signal, [data]) - { return _LAYER.send(signal, data); } + static bool send(String signal, [data]) { + return _LAYER.send(signal, data); + } - static bool remove(String signal, {Object scope, WireListener listener}) - { return _LAYER.remove(signal, scope, listener); } + static bool remove(String signal, {Object scope, WireListener listener}) { + return _LAYER.remove(signal, scope, listener); + } - static WireData data(String param, [dynamic value]) - { + static WireData data(String param, [dynamic value]) { var wd = _STORE.get(param); if (value != null) wd.value = value is Function ? value(wd.value) : value; return wd; diff --git a/lib/src/store.dart b/lib/src/store.dart index c2574e4e..50d1ccd9 100644 --- a/lib/src/store.dart +++ b/lib/src/store.dart @@ -5,8 +5,7 @@ part of wire; /// Github: https://github.com/DQvsRA /// License: APACHE LICENSE, VERSION 2.0 /// -class WireStore -{ +class WireStore { final Map _map = {}; dynamic get(String key) { if (!_map.containsKey(key)) { @@ -15,4 +14,4 @@ class WireStore return _map[key]; } -} \ No newline at end of file +} diff --git a/lib/wire.dart b/lib/wire.dart index 7b73fe0e..731d8359 100644 --- a/lib/wire.dart +++ b/lib/wire.dart @@ -1,3 +1,3 @@ library wire; -export 'src/main.dart'; \ No newline at end of file +export 'src/main.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 8f2a5335..b78de4a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: wire description: Wire is a pub/sub library, event bus with data container, utilize only String key -version: 0.3.1 +version: 0.3.2 homepage: https://github.com/DQvsRA/Wire environment: