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

component-store: An effect declared with type void does not accept a void observable #3462

Closed
1 of 2 tasks
Harpush opened this issue Jun 21, 2022 · 2 comments · Fixed by #3466
Closed
1 of 2 tasks
Labels

Comments

@Harpush
Copy link

Harpush commented Jun 21, 2022

Minimal reproduction of the bug/regression with instructions

An effect with void type argument cannot accept observables as opposed t other types.
image
image

Minimal reproduction of the bug/regression with instructions

Allow passing an observable of type void or nothing.

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

Ngrx 13 with Angular 13

Other information

Originated from discord discussion: https://discord.com/channels/740557383109050469/740560647967866912/988876322086481933

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

  • Yes
  • No
@Harpush Harpush added the bug label Jun 21, 2022
@timdeschryver
Copy link
Member

After some time thinking about this, I realized that (almost) all Observables have a return value.
So, to make this "fix" useful this this would also imply that all types should be accepted as argument?

For now, a workaround would be to create an unknown effect.

someEffect = effect<unknown>(...)

someEffect(eventEmitter)

The more I think about it, the more I think that this is desired:

  • void => used for effects without arguments, effect()
  • type => for effects that have a strict type, effect(1) or effect(Observable<string>)
  • unknown => when you just want to trigger the effect, effect(Observable<unknown|any>)

@Harpush
Copy link
Author

Harpush commented Jun 22, 2022

@timdeschryver Isn't it a bit misleading though? The unknown value will never be used but the effect will accept anything (number, string, etc...). Concerning void - if the argument will be optional wouldn't it solve both? You can pass nothing or an observable compared to number which require a number or observable of numbers.

If there is an observable the returns a number but the effect has no need for it - then unknown might work or just use number and ignore it.

Anyway currently unknown just break out of type checking accepting unknown and not observable of unknown.

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

Successfully merging a pull request may close this issue.

2 participants