Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Fix StreamQueue.withTransaction(). (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Feb 6, 2017
1 parent f7c1f4f commit 878d810
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* Fix a bug where rejecting a `StreamQueueTransaction` would throw a
`StateError` if `StreamQueue.rest` had been called on one of its child queues.

* `StreamQueue.withTransaction()` now properly returns whether or not the
transaction was committed.

## 1.12.0

* Add an `AsyncCache` class that caches asynchronous operations for a period of
Expand Down
1 change: 1 addition & 0 deletions lib/src/stream_queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ abstract class StreamQueue<T> {
} else {
transaction.reject();
}
return result;
}, onError: (error) {
transaction.commit(queue);
throw error;
Expand Down
5 changes: 5 additions & 0 deletions test/stream_queue_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,11 @@ main() {

expect(events.next, completion(3));
});

test("returns whether the transaction succeeded", () {
expect(events.withTransaction((_) async => true), completion(isTrue));
expect(events.withTransaction((_) async => false), completion(isFalse));
});
});

group("cancelable operation", () {
Expand Down

0 comments on commit 878d810

Please sign in to comment.