Currently, I am working with Angular and attempting to retrieve data from the server using websockets. Despite successfully receiving the data from the server, I am faced with a challenge where instead of waiting for the server to send the data, it returns null. For instance:
this.wsService.createObservableSocket(environment.webSocketUrl).subscribe(data=>{
console.log("data received !");
this.messageFromServer = data;
});
//This scenario occurs prior to receiving the data from the server.
// How can I ensure that this only happens after receiving data from the server or
// whenever data is received from the server
this.DoSomething(this.messageFromServer);