Skip to content

Commit

Permalink
Update projects/ngrx.io/content/guide/signals/signal-method.md
Browse files Browse the repository at this point in the history
Co-authored-by: Marko Stanimirović <[email protected]>
  • Loading branch information
rainerhahnekamp and markostanimirovic authored Dec 2, 2024
1 parent baa6fd6 commit 559979e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions projects/ngrx.io/content/guide/signals/signal-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,18 @@ export class NumbersComponent implements OnInit {
At first sight, `signalMethod`, might be the same as `effect`:

```ts
@Component({ /* ... */})
@Component({ /* ... */ })
export class NumbersComponent {
readonly value = signal(2);
readonly num = signal(2);
readonly logDoubledNumberEffect = effect(() => {
const double = num * 2;
console.log(double);
})
console.log(this.num() * 2);
});
readonly logDoubledNumber = signalMethod<number>((num) => {
console.log(num * 2);
});
constructor(): void {
this.logDoubledNumber(value);
constructor() {
this.logDoubledNumber(this.num);
}
}
```
Expand Down

0 comments on commit 559979e

Please sign in to comment.