Fix StreamQueue.withTransaction(). (#24)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index adf53c7..5685503 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/lib/src/stream_queue.dart b/lib/src/stream_queue.dart
index 575cc8a..99e7436 100644
--- a/lib/src/stream_queue.dart
+++ b/lib/src/stream_queue.dart
@@ -328,6 +328,7 @@
} else {
transaction.reject();
}
+ return result;
}, onError: (error) {
transaction.commit(queue);
throw error;
diff --git a/test/stream_queue_test.dart b/test/stream_queue_test.dart
index 7d2fdd4..f487e65 100644
--- a/test/stream_queue_test.dart
+++ b/test/stream_queue_test.dart
@@ -1004,6 +1004,11 @@
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", () {