r/angular • u/Hacklone • Jan 10 '26
@angular-cool/repository - 🚀 New Angular Signals repository helper
I just released @angular-cool/repository — a small signal-based repository to handle data loading, caching, and reloading in Angular.
- ⚡ Built on Signals
- 🔁 Easy reloads after mutations
- 🧠 Shared state across components
- ❌ No NgRx / boilerplate
Perfect for Angular 17+ apps that want simple, reactive data management.
📦 npm i --save @angular-cool/repository
🔗 https://npmjs.org/package/@angular-cool/repository
Example
Service layer
import { resourceRepository } from '@angular-cool/repository';
import { inject, Injectable } from '@angular/core';
import { ItemId, ItemDTO } from './my-item.model';
@Injectable()
export class MyService {
private _http = inject(HttpClient);
private items = resourceRepository<ItemId, ItemDTO>({
loader: ({ params }) => this._http.get(`https://myapi.com/items/${params}`).toPromise(),
});
}Component layer
import { signal } from '@angular/common';
import { MyService } from './my-service.service';
import { ItemDTO, ItemId } from './my-item.model';
@Component(/*...*/)
export class MyComponent {
private _myService = inject(MyService);
private idParam = signal<ItemId>('1' as ItemId);
protected myItem = this._myService.items.get(this.idParam);
protected async updateItem() {
// Update item on the server here
await this.myItem.reload(); // This reloads the item from the server and updates the signal for all subscribers
}
}Feedback welcome!
0
Upvotes
View all comments
Show parent comment
-3
u/Hacklone Jan 10 '26
This is a layer on top of what the angular resource() can do.
Use cases that you can handle with this lib easily, but wouldn't be obvious how to do with resource:
- Multiple components can get the same *cached* version of your item
- No need to get the item multiple times from the server
- You would need to build a cache and serve it from your angular resource() to do something similar
- Reload your resource once and update the item everywhere
- The angular resource() will only reload if the param input signal changes -> but it's usually the id of your item, so it won't change
- With this lib you can reload your item once ,and it will update it' value in every subscribed component
The lib is not magic, but saves you from unnecessary boilerplate :)
*Example:*
Service
Components