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 3, 2024
1 parent e163c10 commit bafa864
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions projects/ngrx.io/content/guide/signals/signal-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,16 @@ By default, the `effect` runs in the injection context of the caller. In the exa
If the call happens outside of an injection context, then the injector of the `signalMethod` is used. This would be the case, if `logDoubledNumber` runs in `ngOnInit`:

```ts

@Component({ /* ... */})
export class NumbersComponent {
readonly logDoubledNumber = signalMethod<number>(num => {
@Component({ /* ... */ })
export class NumbersComponent implements OnInit {
readonly logDoubledNumber = signalMethod<number>((num) => {
const double = num * 2;
console.log(double);
})
});

ngOnInit(): void {
this.logDoubledNumber(1);

const value = signal(2);
// 👇 uses the injection context of the `signalMethod`
// 👇 Uses the injection context of the `NumbersComponent`.
this.logDoubledNumber(value);
}
}
Expand Down

0 comments on commit bafa864

Please sign in to comment.