check function exist

This commit is contained in:
snoop 2017-09-27 17:50:16 +09:00
parent bd23763113
commit 1e63f3782a

View File

@ -8,14 +8,14 @@ export class ServiceInvoker {
public invoke(className: string, methodName: string, params?: any): void { public invoke(className: string, methodName: string, params?: any): void {
let classObj: Object = this.configMap.get(className); let classObj: Object = this.configMap.get(className);
if (classObj === null) { if (classObj === null || classObj === undefined) {
console.log('Error: Cannot find the class. [' + className + ']'); console.log('Error: Cannot find the class. [' + className + ']');
return; return;
} }
if (!classObj.hasOwnProperty(methodName)) { if (classObj[methodName] === undefined) {
console.log('Error: Cannot find the method. [' + methodName + ']'); console.log('Error: Cannot find the method. [' + methodName + ']');
return; return;
} }
classObj[methodName](); classObj[methodName](params);
} }
} }