HookedService<Id, Data, T extends Service<Id, Data> > class
Wraps another service in a service that broadcasts events on actions.
- Inheritance
-
- Object
- Router<
RequestHandler> - Routable
- Service<
Id, Data> - HookedService
Constructors
- HookedService(T inner)
Properties
-
afterCreated
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
afterIndexed
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
afterModified
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
afterRead
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
afterRemoved
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
afterUpdated
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
- app ↔ Angel
-
getter/setter pairinherited
-
beforeCreated
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
beforeIndexed
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
beforeModified
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
beforeRead
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
beforeRemoved
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
beforeUpdated
→ HookedServiceEventDispatcher<
Id, Data, T> -
final
-
bootstrappers
→ List<
RequestHandler> -
Handlers that must run to ensure this service's functionality.
no setteroverride
- configuration → Map
-
A Map of application-specific data that can be accessed.
finalinherited
- container → Container
-
A
Container
used to inject dependencies.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- inner → T
-
Tbe service that is proxied by this hooked one.
final
- isAppActive → bool
-
no setterinherited
-
middleware
→ List<
RequestHandler> -
no setterinherited
-
mounted
→ Map<
Pattern, Router< RequestHandler> > -
no setterinherited
-
onService
→ Stream<
Service> -
Fired whenever a service is added to this instance.
no setterinherited
-
readData
→ (FutureOr<
Data> Function(RequestContext, ResponseContext)?) -
A Function that reads the request body and converts it into
Data
.no setteroverride -
routes
→ List<
Route< RequestHandler> > -
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
services
→ Map<
Pattern, Service> -
A set of
Service
objects that have been mapped into routes.no setterinherited
Methods
-
addHooks(
Angel app) → void - Adds hooks to this instance.
-
addRoute(
String method, String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const {}}) → Route<RequestHandler> -
Adds a route that responds to the given path
for requests with the given method (case-insensitive).
Provide '*' as the method to respond to all methods.
inherited
-
addRoutes(
[Service? service]) → void -
Generates RESTful routes pointing to this class's methods.
override
-
after(
Iterable< String> eventNames, HookedServiceEventListener<Id, Data, T> listener) → void -
Runs the
listener
after every service method specified. -
afterAll(
HookedServiceEventListener< Id, Data, T> listener) → void -
Runs the
listener
after every service method. -
afterAllStream(
) → Stream< HookedServiceEvent< Id, Data, T> > - Returns a Stream of all events fired after every service method.
-
afterStream(
Iterable< String> eventNames) → Stream<HookedServiceEvent< Id, Data, T> > - Returns a Stream of all events fired AFTER every service method specified.
-
all(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to any request matching the given path.
inherited
-
before(
Iterable< String> eventNames, HookedServiceEventListener<Id, Data, T> listener) → void -
Runs the
listener
before every service method specified. -
beforeAll(
HookedServiceEventListener< Id, Data, T> listener) → void -
Runs the
listener
before every service method. -
beforeAllStream(
) → Stream< HookedServiceEvent< Id, Data, T> > - Returns a Stream of all events fired before every service method.
-
beforeModify(
HookedServiceEventListener< Id, Data, T> listener) → void -
Runs the
listener
before create, modify and update. -
beforeStream(
Iterable< String> eventNames) → Stream<HookedServiceEvent< Id, Data, T> > - Returns a Stream of all events fired before every service method specified.
-
chain(
Iterable< RequestHandler> middleware) → ChainedRouter<RequestHandler> -
Prepends the given
middleware
to any routes created by the resulting router.inherited -
clone(
) → Router< RequestHandler> -
Returns a Router with a duplicated version of this tree.
inherited
-
close(
) → Future -
Closes any open StreamControllers on this instance. Internal use only.
override
-
create(
Data data, [Map< String, dynamic> ? params]) → Future<Data> -
Creates a resource.
override
-
delete(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a DELETE request.
inherited
-
dumpTree(
{dynamic callback(String tree)?, String header = 'Dumping route tree:', String tab = ' '}) → void -
Creates a visual representation of the route hierarchy and
passes it to a callback. If none is provided,
print
is called.inherited -
enableCache(
) → void -
Enables the use of a cache to eliminate the overhead of consecutive resolutions of the same path.
inherited
-
findHookedService<
T extends Service> (Pattern path) → HookedService< dynamic, dynamic, T> ? -
Shorthand for finding a HookedService in a statically-typed manner.
inherited
-
findOne(
[Map< String, dynamic> ? params, String errorMessage = 'No record was found matching the given query.']) → Future<Data> -
Retrieves the first object from the result of calling index with the given
params
.inherited -
findService<
T extends Service> (Pattern path) → T? -
Retrieves the service assigned to the given path.
inherited
-
findServiceOf<
Id, Data> (Pattern path) → Service< Id, Data> ? -
Shorthand for finding a Service in a statically-typed manner.
inherited
-
fire(
String eventName, dynamic result, [HookedServiceEventListener< Id, Data, T> ? callback]) → Future<HookedServiceEvent< Id, Data, T> > -
Fires an
after
event. This will not be propagated to clients, but will be broadcasted to WebSockets, etc. -
fireEvent(
HookedServiceEventDispatcher< Id, Data, T> dispatcher, HookedServiceEvent<Id, Data, T> event, [HookedServiceEventListener<Id, Data, T> ? callback]) → Future<HookedServiceEvent< Id, Data, T> > - Sends an arbitrary event down the hook chain.
-
get(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a GET request.
inherited
-
group(
String path, void callback(Router< RequestHandler> router), {Iterable<RequestHandler> middleware = const [], String name = ''}) → SymlinkRoute<RequestHandler> -
Creates a route, and allows you to add child routes to it
via a Router instance.
inherited
-
groupAsync(
String path, FutureOr< void> callback(Router<RequestHandler> router), {Iterable<RequestHandler> middleware = const [], String name = ''}) → Future<SymlinkRoute< RequestHandler> > -
Asynchronous equivalent of group.
inherited
-
head(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a HEAD request.
inherited
-
index(
[Map< String, dynamic> ? params]) → Future<List< Data> > -
Retrieves all resources.
override
-
map<
U> (U encoder(Data), Data decoder(U), {FutureOr< U> readData(RequestContext, ResponseContext)?}) → Service<Id, U> -
Creates an AnonymousService that wraps over this one, and maps input and output
using two converter functions.
inherited
-
modify(
Id id, Data data, [Map< String, dynamic> ? params]) → Future<Data> -
Modifies a resource.
override
-
mount(
String path, Router< RequestHandler> router) → SymlinkRoute<RequestHandler> -
Incorporates another Router's routes into this one's.
inherited
-
Generates a URI string based on the given input.
Handy when you have named routes.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onHooked(
HookedService< dynamic, dynamic, Service> hookedService) → void -
Invoked when this service is wrapped within a HookedService.
inherited
-
options(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const {}}) → Route<RequestHandler> -
Adds a route that responds to a OPTIONS request.
inherited
-
patch(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a PATCH request.
inherited
-
post(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a POST request.
inherited
-
put(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route -
Adds a route that responds to a PUT request.
inherited
-
read(
Id id, [Map< String, dynamic> ? params]) → Future<Data> -
Retrieves the desired resource.
override
-
readMany(
List< Id> ids, [Map<String, dynamic> ? params]) → Future<List< Data> > -
Reads multiple resources at once.
inherited
-
remove(
Id id, [Map< String, dynamic> ? params]) → Future<Data> -
Removes the given resource.
override
-
resolve(
String absolute, String relative, List< RoutingResult< out, {String method = 'GET', bool strip = true}) → boolRequestHandler?> > -
Finds the first Route that matches the given path,
with the given method.
inherited
-
resolveAbsolute(
String path, {String method = 'GET', bool strip = true}) → Iterable< RoutingResult< RequestHandler> > -
Returns the result of resolve with
path
passed as bothabsolute
andrelative
.inherited -
resolveAll(
String absolute, String relative, {String method = 'GET', bool strip = true}) → Iterable< RoutingResult< RequestHandler> > -
Finds every possible Route that matches the given path,
with the given method.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
Id id, Data data, [Map< String, dynamic> ? params]) → Future<Data> -
Overwrites a resource.
override
-
use<
Id, Data, T extends Service< (Id, Data> >String path, T service) → HookedService< Id, Data, T> -
Mounts a
service
at the givenpath
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited