Skip to content

Commit 29fa022

Browse files
committed
NgRx Signals v18 stable upgrade + revamp stores
1 parent 6e7d838 commit 29fa022

17 files changed

+1931
-2578
lines changed

TEMPLATE_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.0.0-alpha.1
1+
v1.0.0-alpha.2

app/eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const eslint = require("@eslint/js");
33
const tseslint = require("typescript-eslint");
44
const angular = require("angular-eslint");
55
const eslintConfigPrettier = require("eslint-config-prettier");
6+
const ngrx = require("@ngrx/eslint-plugin/v9");
67

78
module.exports = tseslint.config(
89
{
@@ -13,6 +14,8 @@ module.exports = tseslint.config(
1314
...tseslint.configs.stylisticTypeChecked,
1415
...angular.configs.tsRecommended,
1516
eslintConfigPrettier,
17+
...ngrx.configs.operators,
18+
...ngrx.configs.signals,
1619
],
1720
languageOptions: {
1821
parserOptions: {

app/package.json

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,55 @@
1919
},
2020
"private": true,
2121
"dependencies": {
22-
"@angular/animations": "^18.1.0",
23-
"@angular/cdk": "18.1.0",
24-
"@angular/common": "^18.1.0",
25-
"@angular/compiler": "^18.1.0",
26-
"@angular/core": "^18.1.0",
27-
"@angular/forms": "^18.1.0",
28-
"@angular/material": "18.1.0",
29-
"@angular/platform-browser": "^18.1.0",
30-
"@angular/platform-browser-dynamic": "^18.1.0",
31-
"@angular/platform-server": "^18.1.0",
32-
"@angular/router": "^18.1.0",
33-
"@angular/service-worker": "^18.1.0",
34-
"@angular/ssr": "^18.1.0",
35-
"@ngrx/operators": "^18.0.1",
36-
"@ngrx/signals": "^18.0.0-rc.2",
22+
"@angular/animations": "^18.1.3",
23+
"@angular/cdk": "18.1.2",
24+
"@angular/common": "^18.1.3",
25+
"@angular/compiler": "^18.1.3",
26+
"@angular/core": "^18.1.3",
27+
"@angular/forms": "^18.1.3",
28+
"@angular/material": "18.1.2",
29+
"@angular/platform-browser": "^18.1.3",
30+
"@angular/platform-browser-dynamic": "^18.1.3",
31+
"@angular/platform-server": "^18.1.3",
32+
"@angular/router": "^18.1.3",
33+
"@angular/service-worker": "^18.1.3",
34+
"@angular/ssr": "^18.1.3",
35+
"@ngrx/operators": "^18.0.2",
36+
"@ngrx/signals": "^18.0.2",
3737
"consola": "^3.2.3",
3838
"express": "^4.19.2",
39-
"firebase": "^10.12.3",
39+
"firebase": "^10.12.4",
4040
"ngxtension": "^4.0.0",
4141
"rxfire": "^6.0.6-canary.5cfad21",
4242
"rxjs": "~7.8.0",
4343
"tslib": "^2.3.0",
44-
"type-fest": "^4.22.0",
45-
"zone.js": "~0.14.5"
44+
"type-fest": "^4.23.0",
45+
"zone.js": "~0.14.8"
4646
},
4747
"devDependencies": {
48-
"@angular-devkit/build-angular": "^18.1.0",
49-
"@angular/cli": "^18.1.0",
50-
"@angular/compiler-cli": "^18.1.0",
48+
"@angular-devkit/build-angular": "^18.1.3",
49+
"@angular/cli": "^18.1.3",
50+
"@angular/compiler-cli": "^18.1.3",
51+
"@ngrx/eslint-plugin": "^18.0.2",
5152
"@types/express": "^4.17.17",
5253
"@types/jasmine": "~5.1.0",
53-
"@types/node": "^20.14.11",
54+
"@types/node": "^22.0.2",
5455
"angular-eslint": "^18.1.0",
5556
"autoprefixer": "^10.4.19",
56-
"eslint": "^9.7.0",
57+
"eslint": "^9.8.0",
5758
"eslint-config-prettier": "^9.1.0",
58-
"jasmine-core": "~5.1.2",
59-
"karma": "~6.4.3",
59+
"jasmine-core": "~5.2.0",
60+
"karma": "~6.4.4",
6061
"karma-chrome-launcher": "~3.2.0",
6162
"karma-coverage": "~2.2.0",
6263
"karma-jasmine": "~5.1.0",
6364
"karma-jasmine-html-reporter": "~2.1.0",
6465
"ng-mocks": "^14.12.2",
65-
"postcss": "^8.4.38",
66+
"postcss": "^8.4.40",
6667
"prettier": "^3.3.3",
6768
"prettier-plugin-tailwindcss": "^0.6.5",
68-
"tailwindcss": "^3.4.6",
69-
"typescript": "~5.5.3",
70-
"typescript-eslint": "^8.0.0-alpha.44"
69+
"tailwindcss": "^3.4.7",
70+
"typescript": "~5.5.4",
71+
"typescript-eslint": "^8.0.0"
7172
}
7273
}

app/pnpm-lock.yaml

Lines changed: 1180 additions & 1818 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/app/logbook/data/config.store.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Config } from '@app-shared/models';
22
import { MockBuilder, MockInstance, ngMocks } from 'ng-mocks';
33
import { of } from 'rxjs';
4-
import { ConfigStore } from './config.store';
4+
import { ConfigStore, ConfigStoreInstanceType } from './config.store';
55
import { ConfigService } from './db/config.service';
66

77
describe('ConfigStore', () => {
@@ -13,7 +13,7 @@ describe('ConfigStore', () => {
1313
const mockConfig: Config = { categories: ['test'] };
1414
MockInstance(ConfigService, 'getConfig$', () => of(mockConfig));
1515

16-
const store = ngMocks.get(ConfigStore);
16+
const store = ngMocks.get<ConfigStoreInstanceType>(ConfigStore);
1717
expect(store).toBeTruthy();
1818
expect(store.status()).toEqual('connected');
1919
expect(store.categories()).toEqual(['test']);
@@ -23,7 +23,7 @@ describe('ConfigStore', () => {
2323
const mockConfig: Config = { categories: ['test'] };
2424
MockInstance(ConfigService, 'getConfig$', () => of(mockConfig));
2525

26-
const store = ngMocks.get(ConfigStore);
26+
const store = ngMocks.get<ConfigStoreInstanceType>(ConfigStore);
2727
store.manageStream('disconnect');
2828
expect(store.status()).toEqual('disconnected');
2929
expect(store.categories()).toEqual([]);

app/src/app/logbook/data/config.store.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, effect, inject } from '@angular/core';
1+
import { effect, inject } from '@angular/core';
22
import { createLogger } from '@app-shared/logger';
33
import { Config } from '@app-shared/models';
44
import { tapResponse } from '@ngrx/operators';
@@ -48,7 +48,9 @@ const initialState: ConfigState = {
4848

4949
const logger = createLogger('ConfigStore');
5050

51-
const _ConfigStore = signalStore(
51+
export type ConfigStoreInstanceType = InstanceType<typeof ConfigStore>;
52+
53+
export const ConfigStore = signalStore(
5254
withState<ConfigState>(initialState),
5355
withMethods((store) => {
5456
const configService = inject(ConfigService);
@@ -118,6 +120,3 @@ const _ConfigStore = signalStore(
118120
},
119121
}),
120122
);
121-
122-
@Injectable()
123-
export class ConfigStore extends _ConfigStore {}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { AuthStore } from '@app-shared/auth/data/auth.store';
22
import { MockBuilder, MockInstance, ngMocks } from 'ng-mocks';
33
import { EntriesService } from './db/entries.service';
4-
import { EntriesUpdateStore } from './entries-update.store';
4+
import { EntriesUpdateStore, EntriesUpdateStoreInstanceType } from './entries-update.store';
55

66
describe('EntriesUpdateStore', () => {
77
MockInstance.scope();
88

99
beforeEach(() => MockBuilder(EntriesUpdateStore, null).mock(AuthStore).mock(EntriesService));
1010

1111
it('should create', () => {
12-
const store = ngMocks.get(EntriesUpdateStore);
12+
const store = ngMocks.get<EntriesUpdateStoreInstanceType>(EntriesUpdateStore);
1313
expect(store).toBeTruthy();
1414
});
1515
});

app/src/app/logbook/data/entries-update.store.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, effect, inject } from '@angular/core';
1+
import { effect, inject } from '@angular/core';
22
import { AuthStore } from '@app-shared/auth/data/auth.store';
33
import { createLogger } from '@app-shared/logger';
44
import { NewOrUpdatedEntryInput } from '@app-shared/models';
@@ -27,7 +27,9 @@ const initialState: EntriesUpdateState = {
2727

2828
const logger = createLogger('EntriesUpdateStore');
2929

30-
const _EntriesUpdateStore = signalStore(
30+
export type EntriesUpdateStoreInstanceType = InstanceType<typeof EntriesUpdateStore>;
31+
32+
export const EntriesUpdateStore = signalStore(
3133
withState(initialState),
3234
withMethods((store) => {
3335
const authStore = inject(AuthStore);
@@ -123,6 +125,3 @@ const _EntriesUpdateStore = signalStore(
123125
},
124126
}),
125127
);
126-
127-
@Injectable()
128-
export class EntriesUpdateStore extends _EntriesUpdateStore {}

app/src/app/logbook/data/entries.store.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AuthStore } from '@app-shared/auth/data/auth.store';
22
import { MockBuilder, MockInstance, ngMocks } from 'ng-mocks';
33
import { of } from 'rxjs';
44
import { EntriesService } from './db/entries.service';
5-
import { EntriesStore } from './entries.store';
5+
import { EntriesStore, EntriesStoreInstanceType } from './entries.store';
66

77
describe('EntriesStore', () => {
88
MockInstance.scope();
@@ -13,7 +13,7 @@ describe('EntriesStore', () => {
1313
MockInstance(AuthStore, 'user$', of(null));
1414
MockInstance(EntriesService, 'getEntryDocs$', () => of([]));
1515

16-
const store = ngMocks.get(EntriesStore);
16+
const store = ngMocks.get<EntriesStoreInstanceType>(EntriesStore);
1717
expect(store).toBeTruthy();
1818
});
1919
});

0 commit comments

Comments
 (0)