I am working with Angular 6 and I need to monitor a variable for any changes and then stop or unsubscribe when the variable has a value.
My initial thought was to use an Observable:
myValue; // The variable that needs to be monitored
myObservable = Observable.timer(2000); // Every 2 seconds
myObservable.subscribe(); // Start monitoring
Then, continue checking myValue and once it is not empty,
myObservable.unsubscribe(); // Stop monitoring
This is the basic outline of what I want to achieve...
What would be the best way to implement this?