Here is a simplified version of my current code:
const getAuthorizedConnection = () => {
let myAuthorizedConnection;
flowable.subscribe({
onComplete: connection => {
connection
.authorize(
authorizedConnection => {
myAuthorizedConection = authorizedConnection;
}
)
.subscribe(
messageFromConnection => {
processMessage(messageFromConnection);
}
);
}
});
return myAuthorizedConnection;
}
While the above code is incorrect, I believe using a Promise could help in returning the authorizedConnection when it's ready and saving it to a variable for reusability. However, I am struggling to implement this change. Can anyone provide guidance on how to correct this?