after method

void after(
  1. Iterable<String> eventNames,
  2. HookedServiceEventListener<Id, Data, T> listener
)

Runs the listener after every service method specified.

Implementation

void after(Iterable<String> eventNames,
    HookedServiceEventListener<Id, Data, T> listener) {
  eventNames.map((name) {
    switch (name) {
      case HookedServiceEvent.indexed:
        return afterIndexed;
      case HookedServiceEvent.read:
        return afterRead;
      case HookedServiceEvent.created:
        return afterCreated;
      case HookedServiceEvent.modified:
        return afterModified;
      case HookedServiceEvent.updated:
        return afterUpdated;
      case HookedServiceEvent.removed:
        return afterRemoved;
      default:
        throw ArgumentError('Invalid service method: $name');
    }
  }).forEach((HookedServiceEventDispatcher<Id, Data, T> dispatcher) =>
      dispatcher.listen(listener));
}