@angular-cool/repository 21.0.1 → 21.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
[npm-url]: https://npmjs.org/package/@angular-cool/repository
|
|
2
|
+
|
|
2
3
|
[npm-image]: https://img.shields.io/npm/v/@angular-cool/repository.svg
|
|
4
|
+
|
|
3
5
|
[downloads-image]: https://img.shields.io/npm/dm/@angular-cool/repository.svg
|
|
6
|
+
|
|
4
7
|
[total-downloads-image]: https://img.shields.io/npm/dt/@angular-cool/repository.svg
|
|
5
8
|
|
|
6
9
|
# @angular-cool/repository [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Total Downloads][total-downloads-image]][npm-url]
|
|
10
|
+
|
|
7
11
|
Cool stateful signal repository for angular
|
|
8
12
|
|
|
9
13
|
An easy-to-use signal repository that helps you manage your data loading and caching in your angular applications.
|
|
10
14
|
|
|
15
|
+
Share data across multiple components and services with automatic reloading and state management.
|
|
16
|
+
|
|
11
17
|
## Install
|
|
18
|
+
|
|
12
19
|
> npm install --save @angular-cool/repository
|
|
13
20
|
|
|
14
21
|
## Usage
|
|
@@ -18,14 +25,14 @@ An easy-to-use signal repository that helps you manage your data loading and cac
|
|
|
18
25
|
```typescript
|
|
19
26
|
import { resourceRepository } from '@angular-cool/repository';
|
|
20
27
|
import { inject, Injectable } from '@angular/core';
|
|
21
|
-
import { ItemId } from './my-item.model';
|
|
28
|
+
import { ItemId, ItemDTO } from './my-item.model';
|
|
22
29
|
|
|
23
30
|
@Injectable()
|
|
24
31
|
export class MyService {
|
|
25
32
|
private _http = inject(HttpClient);
|
|
26
33
|
|
|
27
|
-
private items = resourceRepository<ItemId>({
|
|
28
|
-
loader: ({ params }) => this._http.get(`https://myapi.com/items/${params}`).toPromise(),
|
|
34
|
+
private items = resourceRepository<ItemId, ItemDTO>({
|
|
35
|
+
loader: ({ params }) => this._http.get(`https://myapi.com/items/${ params }`).toPromise(),
|
|
29
36
|
});
|
|
30
37
|
}
|
|
31
38
|
```
|
|
@@ -35,24 +42,26 @@ export class MyService {
|
|
|
35
42
|
```typescript
|
|
36
43
|
import { signal } from '@angular/common';
|
|
37
44
|
import { MyService } from './my-service.service';
|
|
45
|
+
import { ItemId, ItemDTO } from './my-item.model';
|
|
38
46
|
|
|
39
47
|
@Component(/*...*/)
|
|
40
48
|
export class MyComponent {
|
|
41
49
|
private _myService = inject(MyService);
|
|
42
50
|
|
|
43
|
-
private idParam = signal('1');
|
|
51
|
+
private idParam = signal<ItemId>('1' as ItemId);
|
|
44
52
|
|
|
45
|
-
protected myItem = this._myService.items.get(this.idParam);
|
|
53
|
+
protected myItem: Resource<ItemDTO | undefined> = this._myService.items.get(this.idParam);
|
|
46
54
|
|
|
47
55
|
protected updateItem() {
|
|
48
56
|
// Update item on the server here
|
|
49
57
|
|
|
50
|
-
this._myService.items.reload(this.idParam());
|
|
58
|
+
this._myService.items.reload(this.idParam()); // This reloads the item from the server and updates the signal for all subscribers
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
```
|
|
54
62
|
|
|
55
63
|
## License
|
|
64
|
+
|
|
56
65
|
> The MIT License (MIT)
|
|
57
66
|
|
|
58
67
|
> Copyright (c) 2025 Hacklone
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-cool/repository",
|
|
3
3
|
"description": "Cool stateful signal repository for angular",
|
|
4
|
-
"version": "21.0.
|
|
4
|
+
"version": "21.0.2",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/common": ">=21.0.0",
|
|
7
7
|
"@angular/core": ">=21.0.0"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"angular",
|
|
18
|
+
"signal",
|
|
18
19
|
"repository",
|
|
19
20
|
"cache",
|
|
20
21
|
"pattern",
|