Skip to content

Commit

Permalink
chore(demo): use signal (#9229)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Sep 27, 2024
1 parent ce4f05d commit 7b9ea1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions projects/demo/src/modules/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {OnInit} from '@angular/core';
import {Component, DestroyRef, inject, ViewEncapsulation} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {takeUntilDestroyed, toSignal} from '@angular/core/rxjs-interop';
import {NavigationEnd, Router} from '@angular/router';
import {changeDetection} from '@demo/emulate/change-detection';
import {environment} from '@demo/environments/environment';
Expand Down Expand Up @@ -62,11 +62,14 @@ export class App extends AbstractDemo implements OnInit {
protected readonly routes = DemoRoute;
protected readonly playground = environment.playground;

protected readonly isLanding$ = this.router.events.pipe(
filter((event) => event instanceof NavigationEnd),
map(() => this.url === '' || this.url === '/'),
distinctUntilChanged(),
startWith(true),
protected readonly isLanding = toSignal(
this.router.events.pipe(
filter((event) => event instanceof NavigationEnd),
map(() => this.url === '' || this.url === '/'),
distinctUntilChanged(),
startWith(true),
),
{initialValue: true},
);

public override async ngOnInit(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/modules/app/app.template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<router-outlet *ngIf="isLanding$ | async; else portal" />
<router-outlet *ngIf="isLanding(); else portal" />
<ng-template #portal>
<tui-doc-main>
<div
Expand Down

0 comments on commit 7b9ea1a

Please sign in to comment.