blob: ce8ed46a85646aeb1e4028ca00182217e5400b67 [file] [log] [blame] [view]
# bind method
void bind
(T impl, [InterfaceRequest](../../package-fidl_fidl/InterfaceRequest-class.md)<T> interfaceRequest)
<p>Binds the given implementation to the given interface request.</p>
<p>Listens for messages on channel underlying the given interface request,
decodes them, and dispatches the decoded messages to <code>impl</code>.</p>
<p>This object must not already be bound.</p>
<p>The <code>impl</code> and <code>interfaceRequest</code> parameters must not be <code>null</code>. The
<code>channel</code> property of the given <code>interfaceRequest</code> must not be <code>null</code>.</p>
## Implementation
```dart
void bind(T impl, InterfaceRequest<T> interfaceRequest) {
assert(!isBound);
Channel channel = interfaceRequest.passChannel()!;
_impl = impl;
_reader.bind(channel);
final callback = onBind;
if (callback != null) {
callback();
}
}
```