on method
Registers a handler that will be invoked when the hub method with the specified method name is invoked.
methodName: The name of the hub method to define. newMethod: The handler that will be raised when the hub method is invoked.
Implementation
void on(String methodName, MethodInvocationFunc newMethod) {
if (isStringEmpty(methodName)) {
return;
}
methodName = methodName.toLowerCase();
if (_methods[methodName] == null) {
_methods[methodName] = [];
}
// Preventing adding the same handler multiple times.
if (_methods[methodName]!.indexOf(newMethod) != -1) {
return;
}
_methods[methodName]!.add(newMethod);
}