My component calling a function from service which get data through a sdk. Sdk get data and response in a callback function. It returns before getting any response of callback function. How can i inform my component that service callback response done?
Component.ts
async publishSession() {
let publishCallback = await this.myService.publishStream();
}
Service.ts
callbackResponse;
publishStream(publishCapabilities, mediaConstraints) {
this.session = session;
var videoElement = document.getElementsByTagName('video')[0];
var publishOptions = {
publishToken: publishing,
mediaConstraints: mediaConstraints,
videoElement: videoElement
};
return this.sdk.publishToChannel(publishOptions, this.publisherCallback.bind(this));
}
publisherCallback(error, response) {
if (error) {
this.logger.log(error);
}
this.callbackResponse = response; // need this response in component once received here.
}