Skip to content

Commit 348a44c

Browse files
committed
feat(): delete async pipe
1 parent 15c5dcc commit 348a44c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

apps/angular/32-change-detection-bug/src/app/main-navigation.component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { AsyncPipe } from '@angular/common';
21
import { Component, inject, input } from '@angular/core';
2+
import { toSignal } from '@angular/core/rxjs-interop';
33
import { RouterLink, RouterLinkActive } from '@angular/router';
44
import { FakeServiceService } from './fake.service';
55

@@ -37,22 +37,22 @@ export class NavigationComponent {
3737
}
3838

3939
@Component({
40-
imports: [NavigationComponent, AsyncPipe],
40+
imports: [NavigationComponent],
4141
template: `
42-
@if (info$ | async; as info) {
43-
@if (info !== null) {
44-
<app-nav [menus]="getMenu(info)" />
45-
} @else {
46-
<app-nav [menus]="getMenu('')" />
47-
}
42+
@if (info() !== null) {
43+
<app-nav [menus]="getMenu(info()!)" />
44+
} @else {
45+
<app-nav [menus]="getMenu('')" />
4846
}
4947
`,
5048
host: {},
5149
})
5250
export class MainNavigationComponent {
5351
private fakeBackend = inject(FakeServiceService);
5452

55-
readonly info$ = this.fakeBackend.getInfoFromBackend();
53+
readonly info = toSignal(this.fakeBackend.getInfoFromBackend(), {
54+
initialValue: null,
55+
});
5656

5757
getMenu(prop: string) {
5858
return [

0 commit comments

Comments
 (0)