Skip to content

Commit

Permalink
1.3.0: fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Sep 28, 2020
1 parent 682b124 commit 12df45c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 16 deletions.
44 changes: 30 additions & 14 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.3.0 - Sep 29, 2020

- Bugfix: `Uncaught Error: Bad state: Cannot add event after closing`.

## 1.2.0 - Aug 15, 2020

- Updated: `constructor` allow only **`Sink | StreamSubscription`** type.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/disposebag_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ class DisposeBag {
return pairs.map((pair) => pair.second);
}

final sinks = await _disposeByType<Sink>();
final subscriptions = await _disposeByType<StreamSubscription>();
final sinks = await _disposeByType<Sink>();
final resources = {...sinks, ...subscriptions};

_resources.removeAll(resources);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: disposebag
description: A package to help disposing Streams and closing Sinks easily.
version: 1.2.0
version: 1.3.0
homepage: https://github.com/hoc081098/disposebag.git
repository: https://github.com/hoc081098/disposebag.git
issue_tracker: https://github.com/hoc081098/disposebag/issues
Expand Down
21 changes: 21 additions & 0 deletions test/disposebag_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,27 @@ void main() {
await disposeBag.add(mockStreamSubscription);
expect(await disposeBag.clear(), false);
});

test('issue #2', () async {
final bag = DisposeBag();

final controller = StreamController<int>(
onCancel: () => Future.delayed(
const Duration(milliseconds: 10),
),
);

await controller.disposedBy(bag);
await controller.stream.listen(null).disposedBy(bag);

await Stream.periodic(const Duration(milliseconds: 1), (i) => i)
.map((i) => i + 1)
.where((i) => i.isEven)
.listen(controller.add)
.disposedBy(bag);

await bag.dispose();
});
});

group('Extensions', () {
Expand Down

0 comments on commit 12df45c

Please sign in to comment.