Fix up hooked service
This commit is contained in:
parent
3202329490
commit
0420046d7e
3 changed files with 36 additions and 26 deletions
|
@ -1,3 +1,7 @@
|
|||
# 2.0.0-rc.9
|
||||
* Fix some bugs in the `HookedService` implementation that skipped
|
||||
the outputs of `before` events.
|
||||
|
||||
# 2.0.0-rc.8
|
||||
* Fix `MapService` flaw where clients could remove all records, even if `allowRemoveAll` were `false`.
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
params: params))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return beforeIndexed
|
||||
return afterIndexed
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.indexed,
|
||||
params: params, result: before.result))
|
||||
|
@ -302,7 +302,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
id: id, params: params))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return beforeRead
|
||||
return afterRead
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.read,
|
||||
id: id, params: params, result: before.result))
|
||||
|
@ -328,18 +328,18 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
data: data, params: params))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return beforeCreated
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
data: data, params: params, result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.create(data, params).then((result) {
|
||||
return afterCreated
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
data: data, params: params, result: result))
|
||||
data: before.data, params: params, result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.create(before.data, params).then((result) {
|
||||
return afterCreated
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
data: before.data, params: params, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
|
@ -354,18 +354,21 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
id: id, data: data, params: params))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return beforeModified
|
||||
return afterModified
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.modified,
|
||||
id: id, data: data, params: params, result: before.result))
|
||||
id: id,
|
||||
data: before.data,
|
||||
params: params,
|
||||
result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.modify(id, data, params).then((result) {
|
||||
return inner.modify(id, before.data, params).then((result) {
|
||||
return afterModified
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
id: id, data: data, params: params, result: result))
|
||||
id: id, data: before.data, params: params, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
|
@ -380,18 +383,21 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
id: id, data: data, params: params))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return beforeUpdated
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.updated,
|
||||
id: id, data: data, params: params, result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.update(id, data, params).then((result) {
|
||||
return afterUpdated
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.updated,
|
||||
id: id, data: data, params: params, result: result))
|
||||
id: id,
|
||||
data: before.data,
|
||||
params: params,
|
||||
result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.update(id, before.data, params).then((result) {
|
||||
return afterUpdated
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.updated,
|
||||
id: id, data: before.data, params: params, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
|
@ -406,7 +412,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
id: id, params: params))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return beforeRemoved
|
||||
return afterRemoved
|
||||
._emit(new HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.removed,
|
||||
id: id, params: params, result: before.result))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_framework
|
||||
version: 2.0.0-rc.8
|
||||
version: 2.0.0-rc.9
|
||||
description: A high-powered HTTP server with dependency injection, routing and much more.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_framework
|
||||
|
|
Loading…
Reference in a new issue