Search⌘ K
AI Features

The Imperative Pattern for Autosave

Explore the imperative pattern for autosave in Angular reactive forms by tracking form changes with valueChanges observable. Understand the challenges of using nested subscriptions in saving form data and the risks of sending parallel requests that can cause data inconsistency. This lesson helps you grasp why avoiding imperative code and managing HTTP requests properly is crucial for a reliable autosave feature in reactive applications.

Building a recipe creation form

We used Angular reactive forms to build the “New Recipe” creation form. As described in Using RxJS in Angular and Its Advantages, reactive forms leverage RxJS by using the valueChanges observable to track the FormControl changes. This makes our jobs easier since we want to listen to the form’s value changes in order to perform a save on every change. The HTML code of the “New Recipe” creation form is in the recipe-creation.component.html file.

In ...