Skip to content
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

Adding new withMethods causes NgRx signal store to return store: {[p:string]: function():?) #4347

Closed
2 tasks
dreamstar-enterprises opened this issue May 19, 2024 · 4 comments

Comments

@dreamstar-enterprises
Copy link

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

store

Minimal reproduction of the bug/regression with instructions

Hi,

I have a signal store. Its fairly long

It has:

  withState(initialState),

 withNetworkAPIServices(),

 withExtraStoreServices(),

 withMethods((store) => {...})

 withComputed((store) => {...})

 withMethods((store) => {...}) --> all fine upto this point

 withMethods((store) => {}) --> adding another withMethods (even it is blank) causes the below:
  • store in the method returns store: {[p:string]: function():?)
  • all the above signalfactories return Signal<?>
  • and basically everything breaks

Not sure why this is.. I'm just adding another empty withMethods((store) => {})

Sachin

Expected behavior

Should just be possible to add another withMethods

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

NgRx Signal Stores
JetBrains Ultimate

Other information

No response

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

  • Yes
  • No
@jyjor
Copy link

jyjor commented May 23, 2024

I have seen this same problem before when a previous with*** function had an error in it. In my case, there was no TypeScript error and the only indication that something was wrong was that the store stopped working.
Assuming you are experiencing the same thing, try commenting out the withMethods((store) => {...}) --> all fine upto this point function call, and check to see if the store in the final withMethods then works. If it does, you should be able to incrementally uncomment code until you can isolate the exact spot that is causing the error.

@timdeschryver
Copy link
Member

Please provide a reproduction, otherwise we won't be able to investigate this.

store in the method returns store: {[p:string]: function():?)

Side note, this returns a void, while withMethods expects an object.

// returns void
withMethods((store) => {})

// add braces to return an empty object
withMethods((store) => ({}))

I have a signal store. Its fairly long

The underlying issue might be related to #4314

@markostanimirovic
Copy link
Member

Feel free to reopen this issue with the provided reproduction.

@markostanimirovic markostanimirovic closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2024
@dreamstar-enterprises
Copy link
Author

Hi Mark,

I think I hit some sort of limit, as I ended up spliting the store into two, and it worked without any problems (about 5 withStatements... in each)

I think there have been some suggestions for adding some kind of builder method, but I'm very happy so far with my NgRx experience so far. It's completely organised my code base (for variables)

The NgRx documentation is also very good.

My only feedback perhaps would be some examples on deep signals, as I had problems using the inbuilt Entity method, and ended up creating my own deep signalled Map property, that had dynamic keys, and with them objects as values.

Apart from that, I'm happy so far.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants