bindMethod<R, T> method
Implementation
int bindMethod<R, T>(String name, FutureOr<R> Function(T args) body) {
if (intercom.isInitialized) {
throw StateError('Cannot bind to running instance');
}
return intercom.listener.addListener((data) {
try {
var msg = Message.fromJson(assertTyped(data));
if (msg.type != MessageType.CALL_REQUEST) {
return true;
}
var req = CallRequest.fromJson((assertTyped(msg.content)));
if (req.method != name) return true;
_handleMethodCall(name, body, req);
return false;
} on TypeAssertionError {
return true;
}
});
}