From the course: Angular: Testing and Debugging

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Working with observables

Working with observables - Angular Tutorial

From the course: Angular: Testing and Debugging

Start my 1-month free trial

Working with observables

- Let's update the user list component to save and retrieve the filter state from our mock remote server. I'll start by updating the NG on a nit method. First, I'll delete this line here and type this dot web storage service dot get remote. The get remote method doesn't take any arguments so there's nothing to pass in. It does however, return an observable. So we'll subscribe to that response. The callback of the subscribed method is our filter string. So we can work with that value directly. I'll type filtered and then I'll use the arrow syntax for the callback and into the body of this callback we can just reuse the code from this line here. Line 20, cut paste. The wavy line under the await keyword tells us that we can only use this keyword in an asynchronous function. We now have two options for refactoring the code. The first option is to use JavaScript's async await syntax to resolve the promise before assigning it to the user's property. Async await gives us full control of the…

Contents