Skip to content

Commit b3b21e6

Browse files
feat(component): remove $ prefix from LetViewContext property names (#3670)
BREAKING CHANGES: The `$` prefix is removed from `LetViewContext` property names. BEFORE: ```html <ng-container *ngrxLet="obs$; $error as e; $complete as c"> ... </ng-container> ``` AFTER: ```html <ng-container *ngrxLet="obs$; error as e; complete as c"> ... </ng-container> ```
1 parent 5cfd671 commit b3b21e6

File tree

4 files changed

+53
-32
lines changed

4 files changed

+53
-32
lines changed

modules/component/spec/let/let.directive.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ import { stripSpaces } from '../helpers';
3333

3434
@Component({
3535
template: `
36-
<ng-container
37-
*ngrxLet="value$ as value; $error as error; $complete as complete"
38-
>{{
39-
value === null ? 'null' : (value | json) || 'undefined'
40-
}}</ng-container
41-
>
36+
<ng-container *ngrxLet="value$ as value">{{
37+
value === null ? 'null' : (value | json) || 'undefined'
38+
}}</ng-container>
4239
`,
4340
})
4441
class LetDirectiveTestComponent {
@@ -47,7 +44,7 @@ class LetDirectiveTestComponent {
4744

4845
@Component({
4946
template: `
50-
<ng-container *ngrxLet="value$; $error as error">{{
47+
<ng-container *ngrxLet="value$; error as error">{{
5148
error === undefined ? 'undefined' : error
5249
}}</ng-container>
5350
`,
@@ -58,7 +55,7 @@ class LetDirectiveTestErrorComponent {
5855

5956
@Component({
6057
template: `
61-
<ng-container *ngrxLet="value$; $complete as complete">{{
58+
<ng-container *ngrxLet="value$; complete as complete">{{
6259
complete
6360
}}</ng-container>
6461
`,
@@ -69,7 +66,7 @@ class LetDirectiveTestCompleteComponent {
6966

7067
@Component({
7168
template: `
72-
<ng-container *ngrxLet="value$ as value; $suspense as s">{{
69+
<ng-container *ngrxLet="value$ as value; suspense as s">{{
7370
s ? 'suspense' : value
7471
}}</ng-container>
7572
`,

modules/component/src/let/let.directive.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ export interface LetViewContext<PO> {
2424
*/
2525
ngrxLet: LetViewContextValue<PO>;
2626
/**
27-
* `*ngrxLet="obs$; let e = $error"` or `*ngrxLet="obs$; $error as e"`
27+
* `*ngrxLet="obs$; let e = error"` or `*ngrxLet="obs$; error as e"`
2828
*/
29-
$error: any;
29+
error: any;
3030
/**
31-
* `*ngrxLet="obs$; let c = $complete"` or `*ngrxLet="obs$; $complete as c"`
31+
* `*ngrxLet="obs$; let c = complete"` or `*ngrxLet="obs$; complete as c"`
3232
*/
33-
$complete: boolean;
33+
complete: boolean;
3434
/**
35-
* `*ngrxLet="obs$; let s = $suspense"` or `*ngrxLet="obs$; $suspense as s"`
35+
* `*ngrxLet="obs$; let s = suspense"` or `*ngrxLet="obs$; suspense as s"`
3636
*/
37-
$suspense: boolean;
37+
suspense: boolean;
3838
}
3939

4040
/**
@@ -62,7 +62,7 @@ export interface LetViewContext<PO> {
6262
* ### Tracking Different Observable Events
6363
*
6464
* ```html
65-
* <ng-container *ngrxLet="number$ as n; let e = $error; let c = $complete">
65+
* <ng-container *ngrxLet="number$ as n; error as e; complete as c">
6666
* <app-number [number]="n" *ngIf="!e && !c">
6767
* </app-number>
6868
*
@@ -117,53 +117,53 @@ export class LetDirective<PO> implements OnInit, OnDestroy {
117117
private readonly viewContext: LetViewContext<PO | undefined> = {
118118
$implicit: undefined,
119119
ngrxLet: undefined,
120-
$error: undefined,
121-
$complete: false,
122-
$suspense: true,
120+
error: undefined,
121+
complete: false,
122+
suspense: true,
123123
};
124124
private readonly renderEventManager = createRenderEventManager<PO>({
125125
suspense: () => {
126126
this.viewContext.$implicit = undefined;
127127
this.viewContext.ngrxLet = undefined;
128-
this.viewContext.$error = undefined;
129-
this.viewContext.$complete = false;
130-
this.viewContext.$suspense = true;
128+
this.viewContext.error = undefined;
129+
this.viewContext.complete = false;
130+
this.viewContext.suspense = true;
131131

132132
this.renderSuspenseView();
133133
},
134134
next: (event) => {
135135
this.viewContext.$implicit = event.value;
136136
this.viewContext.ngrxLet = event.value;
137-
this.viewContext.$suspense = false;
137+
this.viewContext.suspense = false;
138138

139139
if (event.reset) {
140-
this.viewContext.$error = undefined;
141-
this.viewContext.$complete = false;
140+
this.viewContext.error = undefined;
141+
this.viewContext.complete = false;
142142
}
143143

144144
this.renderMainView(event.synchronous);
145145
},
146146
error: (event) => {
147-
this.viewContext.$error = event.error;
148-
this.viewContext.$suspense = false;
147+
this.viewContext.error = event.error;
148+
this.viewContext.suspense = false;
149149

150150
if (event.reset) {
151151
this.viewContext.$implicit = undefined;
152152
this.viewContext.ngrxLet = undefined;
153-
this.viewContext.$complete = false;
153+
this.viewContext.complete = false;
154154
}
155155

156156
this.renderMainView(event.synchronous);
157157
this.errorHandler.handleError(event.error);
158158
},
159159
complete: (event) => {
160-
this.viewContext.$complete = true;
161-
this.viewContext.$suspense = false;
160+
this.viewContext.complete = true;
161+
this.viewContext.suspense = false;
162162

163163
if (event.reset) {
164164
this.viewContext.$implicit = undefined;
165165
this.viewContext.ngrxLet = undefined;
166-
this.viewContext.$error = undefined;
166+
this.viewContext.error = undefined;
167167
}
168168

169169
this.renderMainView(event.synchronous);

projects/ngrx.io/content/guide/component/let.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ In addition to that it provides us information from the whole observable context
5757
We can track next, error, and complete events:
5858

5959
```html
60-
<ng-container *ngrxLet="number$ as n; let e = $error; let c = $complete">
60+
<ng-container *ngrxLet="number$ as n; error as e; complete as c">
6161
<app-number [number]="n" *ngIf="!e && !c">
6262
</app-number>
6363

projects/ngrx.io/content/guide/migration/v15.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,27 @@ import { LetModule, PushModule } from '@ngrx/component';
144144
})
145145
export class MyFeatureModule {}
146146
```
147+
148+
#### Renamed LetViewContext Properties
149+
150+
The `$` prefix is removed from `LetViewContext` property names.
151+
152+
BEFORE:
153+
154+
`LetViewContext` property names contain the `$` prefix:
155+
156+
```html
157+
<ng-container *ngrxLet="obs$; $error as e; $complete as c">
158+
...
159+
</ng-container>
160+
```
161+
162+
AFTER:
163+
164+
`LetViewContext` property names don't contain the `$` prefix:
165+
166+
```html
167+
<ng-container *ngrxLet="obs$; error as e; complete as c">
168+
...
169+
</ng-container>
170+
```

0 commit comments

Comments
 (0)