From a5a1992d66c034e563f620b148fba4293ae12a82 Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Fri, 30 Apr 2021 12:13:53 +0700 Subject: [PATCH] 1.0.0 --- lib/src/async/async_queue.dart | 9 ++++++--- lib/src/impl/real_storage.dart | 8 ++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/src/async/async_queue.dart b/lib/src/async/async_queue.dart index 5e3d55c..09a0637 100644 --- a/lib/src/async/async_queue.dart +++ b/lib/src/async/async_queue.dart @@ -78,9 +78,12 @@ class AsyncQueue { /// Add block to queue. Future enqueue(AsyncQueueBlock block) { - if (_bag.isDisposed) { - throw StateError('AsyncQueue has been disposed!'); - } + assert(() { + if (_bag.isClearing || _bag.isDisposed) { + throw StateError('AsyncQueue has been disposed!'); + } + return true; + }()); final completer = Completer.sync(); _blockS.add(_AsyncQueueEntry(completer, block)); diff --git a/lib/src/impl/real_storage.dart b/lib/src/impl/real_storage.dart index 40631de..b990b65 100644 --- a/lib/src/impl/real_storage.dart +++ b/lib/src/impl/real_storage.dart @@ -87,16 +87,12 @@ class RealRxStorage event) { assert(_debugAssertNotDisposed()); - try { - _loggerEventController!.add(event); - } on StateError { - assert(_debugAssertNotDisposed()); - } + _loggerEventController!.add(event); } bool _debugAssertNotDisposed() { assert(() { - if (_bag.isDisposed && _disposeMemo.hasRun) { + if (_bag.isClearing || _bag.isDisposed) { throw StateError('A $runtimeType was used after being disposed.\n' 'Once you have called dispose() on a $runtimeType, it can no longer be used.'); }