|
1 | 1 | # Router Component Store changelog
|
2 | 2 |
|
| 3 | +## 15.0.0-rc.2 (2025-02-12) |
| 4 | + |
| 5 | +### Features |
| 6 | + |
| 7 | +- Use `StrictQueryParams` for query parameters instead of `StrictRouteParams` ([#331](https://github.com/ngworker/router-component-store/pull/331)) |
| 8 | + |
| 9 | +Array query parameters like `?size=m&size=l&size=xl` are now correctly resolved to `readonly string[]` instead of `string`. |
| 10 | + |
| 11 | +**BREAKING CHANGES** |
| 12 | + |
| 13 | +**`RouterStore#queryParams$` and `MinimalActivatedRouteSnapshot#queryParams` use `StrictQueryParams`** |
| 14 | + |
| 15 | +`RouterStore#queryParams$` and `MinimalActivatedRouteSnapshot#queryParams` use `StrictQueryParams` instead of `StrictRouteParams`. Members are of type `string | readonly string[] | undefined` instead of `string | undefined`. |
| 16 | + |
| 17 | +The TypeScript compiler will fail to compile code that does not handle the string array type. |
| 18 | + |
| 19 | +BEFORE: |
| 20 | + |
| 21 | +```typescript |
| 22 | +// shirts.component.ts |
| 23 | +// (...) |
| 24 | +import { RouterStore } from '@ngworker/router-component-store'; |
| 25 | + |
| 26 | +@Component({ |
| 27 | + // (...) |
| 28 | +}) |
| 29 | +export class ShirtsComponent { |
| 30 | + #routerStore = inject(RouterStore); |
| 31 | + |
| 32 | + size$: Observable<string> = this.#routerStore.queryParams$.pipe( |
| 33 | + map((params) => params['size']) |
| 34 | + ); |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +AFTER: |
| 39 | + |
| 40 | +```typescript |
| 41 | +// shirts.component.ts |
| 42 | +// (...) |
| 43 | +import { RouterStore } from '@ngworker/router-component-store'; |
| 44 | + |
| 45 | +@Component({ |
| 46 | + // (...) |
| 47 | +}) |
| 48 | +export class ShirtsComponent { |
| 49 | + #routerStore = inject(RouterStore); |
| 50 | + |
| 51 | + size$: Observable<readonly string[]> = this.#routerStore.queryParams$.pipe( |
| 52 | + map((params) => params['size']), |
| 53 | + map((size) => (Array.isArray(size) ? size : [size])) |
| 54 | + ); |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +**`RouterStore#selectQueryParam` use `StrictQueryParams`** |
| 59 | + |
| 60 | +`RouterStore#selectQueryParam` use `StrictQueryParams` instead of `StrictRouteParams`. The returned value is of type `string | readonly string[] | undefined` instead of `string | undefined`. |
| 61 | + |
| 62 | +The TypeScript compiler will fail to compile code that does not handle the string array type. |
| 63 | + |
| 64 | +BEFORE: |
| 65 | + |
| 66 | +```typescript |
| 67 | +// shirts.component.ts |
| 68 | +// (...) |
| 69 | +import { RouterStore } from '@ngworker/router-component-store'; |
| 70 | + |
| 71 | +@Component({ |
| 72 | + // (...) |
| 73 | +}) |
| 74 | +export class ShirtsComponent { |
| 75 | + #routerStore = inject(RouterStore); |
| 76 | + |
| 77 | + size$: Observable<string> = this.#routerStore.selectQueryParam('size'); |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +AFTER: |
| 82 | + |
| 83 | +```typescript |
| 84 | +// shirts.component.ts |
| 85 | +// (...) |
| 86 | +import { RouterStore } from '@ngworker/router-component-store'; |
| 87 | + |
| 88 | +@Component({ |
| 89 | + // (...) |
| 90 | +}) |
| 91 | +export class ShirtsComponent { |
| 92 | + #routerStore = inject(RouterStore); |
| 93 | + |
| 94 | + size$: Observable<readonly string[]> = this.#routerStore |
| 95 | + .selectQueryParam('size') |
| 96 | + .pipe(map((size) => (Array.isArray(size) ? size : [size]))); |
| 97 | +} |
| 98 | +``` |
| 99 | + |
3 | 100 | ## 15.0.0-rc.1 (2024-09-17)
|
4 | 101 |
|
5 | 102 | ### Refactors
|
|
0 commit comments