2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2025-12-17 01:10:25 +00:00

Fix AsyncReply

This commit is contained in:
2022-04-06 02:29:27 +03:00
parent 8479fe59c9
commit aab6c2bebd
4 changed files with 114 additions and 89 deletions

View File

@@ -454,20 +454,24 @@ class Warehouse {
_resources[(resource.instance as Instance).id] = resource;
if (_warehouseIsOpen) {
resource.trigger(ResourceTrigger.Initialize).then<dynamic>((value) {
if (resource is IStore)
resource.trigger(ResourceTrigger.Open).then<dynamic>((value) {
resource.trigger(ResourceTrigger.Initialize)
..then((value) {
if (resource is IStore)
resource.trigger(ResourceTrigger.Open)
..then((value) {
rt.trigger(resource);
})
..error((ex) {
Warehouse.remove(resource);
rt.triggerError(ex);
});
else
rt.trigger(resource);
}).error((ex) {
Warehouse.remove(resource);
rt.triggerError(ex);
});
else
rt.trigger(resource);
}).error((ex) {
Warehouse.remove(resource);
rt.triggerError(ex);
});
})
..error((ex) {
Warehouse.remove(resource);
rt.triggerError(ex);
});
}
};
@@ -475,15 +479,17 @@ class Warehouse {
_stores.add(resource);
initResource();
} else {
store?.put(resource).then<dynamic>((value) {
if (value)
initResource();
else
rt.trigger(null);
}).error((ex) {
Warehouse.remove(resource);
rt.triggerError(ex);
});
store?.put(resource)
?..then((value) {
if (value)
initResource();
else
rt.trigger(null);
})
..error((ex) {
Warehouse.remove(resource);
rt.triggerError(ex);
});
}
// return new name