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

USER_PROVIDED_EFFECTS not working after ngrx/effects@15.2.0 ? #3848

Closed
2 tasks
v-c-git opened this issue Apr 14, 2023 · 2 comments · Fixed by #3851
Closed
2 tasks

USER_PROVIDED_EFFECTS not working after ngrx/effects@15.2.0 ? #3848

v-c-git opened this issue Apr 14, 2023 · 2 comments · Fixed by #3851

Comments

@v-c-git
Copy link

v-c-git commented Apr 14, 2023

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

effects

Minimal reproduction of the bug/regression with instructions

We use USER_PROVIDED_EFFECTS in combination with a function that returns injectable effect tokens from dynamically generated effects like so:
..
{
provide: USER_PROVIDED_EFFECTS,
useValue: getEffectTokens(),
multi: true
}

where getEffectTokens() returns an array like:

export const getEffectTokens = () => [
SOME_EFFECT_TOKEN,
SOME_EFFECT_TOKEN2,
etc
];

And tokens are just NG injection tokens that use factory to create a class that derives from the base effect class in order to reduce boilerplate.

Minimal reproduction of the bug/regression with instructions

The code above worked fine for many releases until 15.2.0. Has something changed starting with that release that would affect USER_PROVIDED_EFFECTS ?

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

NGRX: 15.2 and up
NG 15

Other information

No response

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

  • Yes
  • No
@v-c-git
Copy link
Author

v-c-git commented Apr 14, 2023

And here's the stackblitz:

https://stackblitz.com/edit/angular-ivy-x2cbz5?file=src/app/app.module.ts

If you go there, let it run, then open console and you'll see output from InjectedEffect constructor.

After that install ngrx/effects/15.2.0 or higher

Refresh - no more output from InjectedEffect constructor. It doesn't get called

@markostanimirovic
Copy link
Member

markostanimirovic commented Apr 18, 2023

This was a hidden feature before. 😅

The USER_PROVIDED_EFFECTS token expects an array of classes, not injection tokens. However, the compilation of the following code succeeds:

{ provide: USER_PROVIDED_EFFECTS, useValue: ['anything'] }

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

Successfully merging a pull request may close this issue.

3 participants