I'm currently analyzing different design patterns to optimize the number of REST calls when implementing a 'save while typing feature'. To provide a general overview, in my ngOnInit() function, I have included the following code snippet (with distinctUntilChanged() implementation to avoid excessive REST endpoint calls):
ngOnInit(): void {
if (this.formIsEditable) {
this.inputField.valueChanges.subscribe(() => //do REST);
}
}
The issue I am facing is that formIsEditable is set to true after the component has been initialized, which prevents it from entering the above code block. Is there a method in Angular to trigger an update when this boolean value changes? Essentially, I want to prevent sending a PUT request to the Back End when the boolean is false, and allow it only when the boolean is true.