[00:00] Here we have an example of an Angular application working with observables. It has some variables that we're printing on the page, and it's making an HTTP call to get some information from a server. When you work with observables, your templates can get a bit messy because you find
[00:18] yourself passing the async pipe everywhere and then need to keep track of it. There is a pattern I learned from using NgRx component store and it's called using a view model in your template. For that, we're going to create a new class variable.
[00:36] This is going to be our view model. Here we're going to combine all of these observables. What we want to do is
[00:55] return one single object that has all of our information. Now, we can clean our template a bit by creating one single subscription to our view model. Now, we can move everything inside of an ng-container,
[01:16] and now we can start using our view model. Since we are already using the async pipe here, we are not going to need it anywhere else. Instead, I'm going to get the variables from VM dot and the variable name.
[01:34] You see, when I save, it's going to be exactly the same. I can reload the page and all of my data will still be there. With this, you only need to keep track of
[01:51] one subscription and this is the one for your view model.