Issue
I have this piece of code in my angular 6 application:
publish() {
change.subscribe((result: boolean) => {
if(!result) return; // exit publish function
});
// continue
}
I want this publish function to continue executing only if result is true.
How to manage this ?
Solution
it is impossible, you should put your publish
function code inside your subscription, or there is another way you can do, you can use .toPromise()
and async/await
, if you will get your data one time and not in a stream
async publish() {
const result = await change.toPromise();
if(result) {
// your publish function code here
});
}
Answered By - Artyom Amiryan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.