I've encountered an issue with a component that needs to run code at regular intervals without pausing. I'm currently using an IntervalObservable and need to adjust the interval dynamically. While I can change the variable value using the setTime() function, the observable continues to run at its original interval set during creation. I'm unsure of how to make the observable update its interval. Any assistance would be greatly appreciated.
Component
@Component({
selector: 'my-app',
templateUrl: './graphs.component.html',
styleUrls: ['./graphs.component.css']
})
export class GraphsComponent implements OnInit {
selectedTime:number
selectedRefresh=10
constructor() {
IntervalObservable.create(this.selectedRefresh*1000).subscribe(n => {
//DO THINGS
});
}
setTime() {
this.selectedRefresh = selectedTime*60/(0.3*100)
}
html
<form (keyup.enter)="setTime()"><input type="number" [(ngModel)]="selectedTime" name="time" placeholder="enter mins" ngModel/></form>