diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bfc50c..85a80a33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/lib/src/core/hooked_service.dart b/lib/src/core/hooked_service.dart index f2585246..5a68a028 100644 --- a/lib/src/core/hooked_service.dart +++ b/lib/src/core/hooked_service.dart @@ -276,7 +276,7 @@ class HookedService> 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: 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> 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: 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: 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: 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)) diff --git a/pubspec.yaml b/pubspec.yaml index 40d8b3dd..dc609baf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/angel-dart/angel_framework