Skip to content

rxMethod: can not pass function as parameter #5059

@frenzymind

Description

@frenzymind

Which @ngrx/* package(s) are the source of the bug?

signals

Minimal reproduction of the bug/regression with instructions

Hello. Some trouble with stackblitz for me, can create reproduction later if required.
But issues is simple to reproduce. Create rxMethod:

withMethods(store => {
return {
logDoubledNumber: rxMethod<() => number>(
        pipe(
          tap(fn => {
            console.log(fn);
          }),
          map(fn => fn() * 2),
          tap(console.log)
        )
      )
}}
)

Call this method: this.cameraStore.logDoubledNumber(() => 5);

Log in tap operator shows me 5, not function. So in map when I call it I get ERROR TypeError: fn is not a function
Docs says: "The reactive method can accept a static value, signal, or observable as an input argument" , nothing about function, but it works in signal store v20.
It seems rxMethod execute function under the hood.
For the same time it looks type safe in code editor from typescript perspective, you get error only in runtime.

Expected behavior

I expect to get function. I don't see any issue to pass function, isn't it?
Or did it never be expected? And version 21 fix this? Or version 21 break something?

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

@ngrx/signals": "^21.0.0
@angular/core": "^21.0.5
node:24.12.0
Chrome desktop

Other information

Thanks!

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions