
2025-07-30 16:05:06
🧪 rxResource() — a new Angular 20 feature for reactive data streams
Angular 20 introduced a powerful tool for handling async data — rxResource(). It’s a reactive abstraction over signal() and Observable that automatically handles:
✅ data loading via Observable
✅ canceling previous requests on new calls
✅ status tracking: pending, success, error
✅ caching and reloading
✅ AbortSignal support for cancellation
Usage example:
public readonly response = rxResource({
params: computed(() => ({
page: this.currentPage(),
limit: this.pageSize,
includeTicketsInfo: true
})),
stream: ({ params }) =>
this.eventService.eventControllerFindByCompany(params)
});
No more manual async pipe or subscriptions — now there’s a declarative, reactive API. Fully compatible with signals and template control flow (@if ()).
A solid alternative to ngrx/component-store, custom async wrappers, or even React Query’s useQuery.
#Angular #RxJS #Streams #Signals #Resource #SnackStack
Angular 20 introduced a powerful tool for handling async data — rxResource(). It’s a reactive abstraction over signal() and Observable that automatically handles:
✅ data loading via Observable
✅ canceling previous requests on new calls
✅ status tracking: pending, success, error
✅ caching and reloading
✅ AbortSignal support for cancellation
Usage example:
public readonly response = rxResource({
params: computed(() => ({
page: this.currentPage(),
limit: this.pageSize,
includeTicketsInfo: true
})),
stream: ({ params }) =>
this.eventService.eventControllerFindByCompany(params)
});
No more manual async pipe or subscriptions — now there’s a declarative, reactive API. Fully compatible with signals and template control flow (@if ()).
A solid alternative to ngrx/component-store, custom async wrappers, or even React Query’s useQuery.
#Angular #RxJS #Streams #Signals #Resource #SnackStack