From the course: Reactivity and Signals in Angular

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Implementing resource and rxResource

Implementing resource and rxResource - Angular Tutorial

From the course: Reactivity and Signals in Angular

Implementing resource and rxResource

- [Instructor] HttpResource is a great way for handling HttpClient requests, but not all of our asynchronous code uses HttpClient. We might use timeouts or promises to implement features. We might use generated services that provide methods that return observables. We might use external libraries, like Apollo Client, to make our requests. In these instances, we can use RxResource to handle observables and Resource to handle other async code, like promises. To create a resource, we use the resource function, which accepts a resource options object. This object allows us to define a params property, which is a calculation that is evaluated anytime one of the tracked signals changes. Its behavior is the same as a computed. When the params property gets a new value, it schedules the loader to run. This callback can include logic to determine which parameters to use. The loader property is a resource loader. This is an async function that accepts a single ResourceLoaderParams object as an…

Contents