The code structure provided is as follows:
import {socket} from './socket';
class A{
Execute(...args[]){
//logic with Promises
SomeAsyncMethod1().then(fulfilled1);
function fulfilled1(){
SomeAsyncMethod2(args).then(fulfilled2);
}
function fulfilled2(filled_result){
//(1)
}
}
}
class B{
private a_obj: A;
constructor(){
a_obj = new A();
}
Method1(one: string){
a_obj.Execute(one);
}
Method2(one: number, two: any){
a_obj.Execute(one, two);
}
}
Class C{
interface Ids {
[id: string]: any;
}
let instances: Ids = {};
instances["1"] = new B();
instances["W"] = new B();
CallMethod(callerId: string, objectId: string, methodName: string, args: any[])
instances[objectId][methodName](...args);
//(!) (2)
}
}
"(!)" - I aim to transmit the filled_result
data from fulfilled2
function to the client using its clientId
through the socket
. The challenge lies in retrieving both the clientId
and the filled_result
.
CallMethod(callerId: string, objectId: string, methodName: string, args: any[])
instances[objectId][methodName](...args);
socket.send_results(callerId, filled_result);
}
The dilemma arises as I lack access to the clientId
in (1), similarly, in (2) obtaining the filled_result
presents an obstacle.