Hooks
Hooks
class HookedService extends Service {
HookedServiceEventDispatcher beforeIndexed;
HookedServiceEventDispatcher afterIndexed;
// And so on...
}/// Fired when a hooked service is invoked.
class HookedServiceEvent {
static const String indexed = "indexed";
static const String read = "read";
static const String created = "created";
static const String modified = "modified";
static const String updated = "updated";
static const String removed = "removed";
/// The inner service whose method was hooked.
Service service;
/// The name of the event being fired. This class exposes
/// some constant Strings you can check for, to prevent typos.
String eventName;
/// Read-only: The `id` passed to this event, if any.
var id;
/// Same as `id`.
var data;
/// Same as `id`. Keep in mind, although this is read-only,
/// you can still assign values within it.
Map params;
/// Read-only. After an event completes, this will hold whatever
/// value the service method returned.
var result;
/// If you call this, no further event callbacks will be fired.
/// If called on a 'before' hook, no further 'before' events will fire.
/// Same for an 'after' hook.
///
/// If you call this on a 'before' hook, the actual service method
/// will never be called. Instead, `result` will be returned as the
/// response, and any 'after' hooks will see this value as the `result`.
///
/// This is very useful, and allows another way to filter or deny access to
/// services than traditional middleware.
void cancel(result);
}Bundled Hooks
Next Up...
Last updated