rename holder to entity
This commit is contained in:
parent
86b048b3b4
commit
44ad1a58c7
@ -77,7 +77,7 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
|
||||
}
|
||||
|
||||
export class Context {
|
||||
holder: any
|
||||
entity: any
|
||||
id: string
|
||||
callbacks: Map<string, { resolve: Function, reject: Function }> = new Map
|
||||
constructor(id: string) {
|
||||
@ -95,7 +95,7 @@ export class Context {
|
||||
})
|
||||
}
|
||||
registor(instance: Object) {
|
||||
this.holder = instance
|
||||
this.entity = instance
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,18 +133,22 @@ export function jsRegisterModule(name: string, moduleObject: any) {
|
||||
gModules.set(name, moduleObject)
|
||||
}
|
||||
|
||||
export function jsCallContextMethod(contextId: string, methodName: string, args?: any) {
|
||||
export function jsCallEntityMethod(contextId: string, methodName: string, args?: any) {
|
||||
const context = gContexts.get(contextId)
|
||||
if (context === undefined) {
|
||||
loge(`Cannot find context for context id:${contextId}`)
|
||||
return
|
||||
}
|
||||
if (Reflect.has(context, methodName)) {
|
||||
if (context.entity === undefined) {
|
||||
loge(`Cannot find holder for context id:${contextId}`)
|
||||
return
|
||||
}
|
||||
if (Reflect.has(context.entity, methodName)) {
|
||||
const argumentsList: any = []
|
||||
for (let i = 2; i < arguments.length; i++) {
|
||||
argumentsList.push(arguments[i])
|
||||
}
|
||||
return Reflect.apply(Reflect.get(context, methodName), context, argumentsList)
|
||||
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
|
||||
} else {
|
||||
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
|
||||
}
|
||||
|
Reference in New Issue
Block a user