8000 Display a signal graph for each component by milomg · Pull Request #60478 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

Display a signal graph for each component #60478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add cookies signal demo
  • Loading branch information
milomg committed Jun 26, 2025
commit fd16b849ba9283730d030a9a0fcbb2008c6027b6
1 change: 1 addition & 0 deletions devtools/src/app/demo-app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ sass_binary(
ng_project(
name = "demo-app",
srcs = [
"cookies.component.ts",
"demo-app.component.ts",
"demo-app.routes.ts",
"heavy.component.ts",
Expand Down
38 changes: 38 additions & 0 deletions devtools/src/app/demo-app/cookies.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/

import {Component, signal, computed} from '@angular/core';

@Component({
selector: 'app-cookies',
template: `
<h2>Cookie recipe</h2>

<label>
# of cookies:
<input type="range" min="10" max="100" step="10" [value]="count()" (input)="update($event)" />
{{ count() }}
</label>

<p>Butter: {{ butter() }} cup(s)</p>
<p>Sugar: {{ sugar() }} cup(s)</p>
<p>Flour: {{ flour() }} cup(s)</p>
`,
})
export class CookieRecipe {
count = signal(10, {debugName: 'count'});

butter = computed(() => this.count() * 0.1, {debugName: 'butter'});
sugar = computed(() => this.count() * 0.05, {debugName: 'sugar'});
flour = computed(() => this.count() * 0.2, {debugName: 'flour'});

update(event: Event) {
const input = event.target as HTMLInputElement;
this.count.set(parseInt(input.value));
}
}
1 change: 1 addition & 0 deletions devtools/src/app/demo-app/demo-app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
<app-heavy></app-heavy>
<div #elementReference>HTMLElement</div>
<app-sample-properties></app-sample-properties>
<app-cookies />
3 changes: 2 additions & 1 deletion devtools/src/app/demo-app/demo-app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import {ZippyComponent} from './zippy.component';
import {HeavyComponent} from './heavy.component';
import {SamplePropertiesComponent} from './sample-properties.component';
import {RouterOutlet} from '@angular/router';
import {CookieRecipe} from './cookies.component';

@Component({
selector: 'app-demo-component',
templateUrl: './demo-app.component.html',
styleUrls: ['./demo-app.component.scss'],
encapsulation: ViewEncapsulation.None,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [HeavyComponent, SamplePropertiesComponent, RouterOutlet],
imports: [HeavyComponent, SamplePropertiesComponent, RouterOutlet, CookieRecipe],
})
export class DemoAppComponent {
readonly zippy = viewChild(ZippyComponent);
Expand Down
0