2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2026-04-02 09:38:20 +00:00
This commit is contained in:
2022-01-03 15:39:19 +03:00
parent 614c6853e3
commit eed16df29a
20 changed files with 521 additions and 443 deletions

View File

@@ -23,7 +23,14 @@ class AsyncBag<T> extends AsyncReply<List<T>> {
if (_sealedBag) return;
_sealedBag = true;
if (_replies.length == 0) trigger(<T>[]);
if (_replies.length == 0) {
if (arrayType != null) {
var ar = Warehouse.createArray(arrayType as Type);
trigger(ar as List<T>);
} else {
trigger(<T>[]);
}
}
var results = List<T?>.filled(_replies.length, null);
@@ -31,21 +38,23 @@ class AsyncBag<T> extends AsyncReply<List<T>> {
var k = _replies[i];
var index = i;
k..then((r) {
results[index] = r;
_count++;
if (_count == _replies.length) {
if (arrayType != null) {
var ar = Warehouse.createArray(arrayType as Type);
results.forEach(ar.add);
trigger(ar as List<T>);
} else {
trigger(results.cast<T>());
k
..then((r) {
results[index] = r;
_count++;
if (_count == _replies.length) {
if (arrayType != null) {
var ar = Warehouse.createArray(arrayType as Type);
results.forEach(ar.add);
trigger(ar as List<T>);
} else {
trigger(results.cast<T>());
}
}
}
})..error((ex) {
triggerError(ex);
});
})
..error((ex) {
triggerError(ex);
});
}
}