use<Id, Data, T extends Service<Id, Data>> method

HookedService<Id, Data, T> use <Id, Data, T extends Service<Id, Data>>(
  1. String path,
  2. T service
)

Mounts a service at the given path.

Returns a HookedService that can be used to hook into events dispatched by this service.

Implementation

HookedService<Id, Data, T> use<Id, Data, T extends Service<Id, Data>>(
    String path, T service) {
  var hooked = HookedService<Id, Data, T>(service);
  _services[path.toString().trim().replaceAll(RegExp(r'(^/+)|(/+$)'), '')] =
      hooked;
  hooked.addRoutes();
  mount(path.toString(), hooked);
  service.onHooked(hooked);
  _onService.add(hooked);
  return hooked;
}