From bafa864c561a834157b1f16012a18c2fa553a76c Mon Sep 17 00:00:00 2001 From: Rainer Hahnekamp Date: Tue, 3 Dec 2024 12:30:29 +0100 Subject: [PATCH] Update projects/ngrx.io/content/guide/signals/signal-method.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marko Stanimirović --- .../ngrx.io/content/guide/signals/signal-method.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/projects/ngrx.io/content/guide/signals/signal-method.md b/projects/ngrx.io/content/guide/signals/signal-method.md index 004d3b57b6..7333cd86b1 100644 --- a/projects/ngrx.io/content/guide/signals/signal-method.md +++ b/projects/ngrx.io/content/guide/signals/signal-method.md @@ -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(num => { +@Component({ /* ... */ }) +export class NumbersComponent implements OnInit { + readonly logDoubledNumber = signalMethod((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); } }