setCallBack method

  1. @override
void setCallBack({
  1. required CallBackMethod<MirrorMethodCall, Error> call,
})
override

If call setCallBack to a targetMethod already registered, then will dispose the actual callback listener before continue.

Implementation

@override
void setCallBack({
  required CallBackMethod<MirrorMethodCall, Error> call,
}) {
  if (isAlreadyRegistered(targetMethod: call.message.header.targetMethod)) {
    // throw Exception(
    //     'targetMethod: [call.message.header.targetMethod] already registered.');
    log('SUPOSE TO: \nthrow Exception(\'targetMethod: [call.message.header.targetMethod] already registered.\');',
        level: 2000);
    return;
  }

  _nextCallBackReferenceId++;

  call.message.header.callBackReferenceId = _nextCallBackReferenceId;

  _callbacks.add(call);

  log('CallBacksController, setCallBack -> $_nextCallBackReferenceId : ${call.message.header.targetMethod}');
}