Scenario:
I developed a service that validates signatures (OtpSMS and Position). This service has two main functions:
--> validateSignPosition() : Observable --> validateSignOtpSMS() : Observable
Two functions mentioned are asynchronous because need to demand a challenge to remote server. There is the reason because I used observables to sustain the correct outpour of application.
Problem
I have a restriction about not being able to use ngOnDestroy to unsuscribe this observables. Then, I was thinking about realize unsuscribe action when I recieve data or an error exception. Like this example:
currentObserver = this.service.validateSignOTP().subscribe(
data => { this.currentObserver.unsubscribe() },
error => { this.currentObserver.unsubscribe() }
...
I believe there are another option to not replicate code. I heard about finally/onComplete section which executes although recieves data or exception. But, I do not know if this works with asynchronous outpour...
Do you know how can unsuscribe observables to this scenario?
Thank you.