*[<Null safety>](https://dart.dev/null-safety)*
void exposeService <T extends Service>(FutureOr<T> serviceImpl)
Associate serviceImpl
to this Agent and exposes it to the rest of the
system so that it can be discovered and connected to. Notice that
serviceImpl
is of type FutureOr<T>
, where T
represents the service
type, to enable the ability to wait for any asynchronous operations to
finish before initializing and exposing the service.
Note: Multiple connections will be allowed to this serviceImpl
.
Usage example:
import 'package:fidl_fuchsia_foo/fidl_async.dart' as fidl;
import 'package:fuchsia_modular/agent.dart';
import 'src/foo_service_impl.dart';
void main(List<String> args) {
final context = ComponentContext.create();
Agent()..exposeService(FooServiceImpl())..serve(context.outgoing);
context.outgoing.serveFromStartupInfo();
}
class FooServiceImpl extends fidl.FooService { ... }
Implementation
void exposeService<T extends Service>(FutureOr<T> serviceImpl);