ngneat / effects

🪄 A framework-agnostic RxJS effects implementation
https://www.netbasal.com
MIT License
63 stars 11 forks source link

bug: {dispatch: false} in an effect is ignored in case of {dispatchByDefault: true} #24

Closed theorlovsky closed 2 years ago

theorlovsky commented 2 years ago

Which @ngneat/effects-* package(s) are the source of the bug?

effects

Is this a regression?

No

Description

When you call the initEffects with {dispatchByDefault: true}, you no longer have the option not to dispatch an action from an effect. This is the piece of code that causes the issue:

// effects-manager.ts

if (
  effect.config?.dispatch || // <-- should be ??
  (this.config.dispatchByDefault && checkAction(maybeAction))
) {
  actions.dispatch(maybeAction);
}

I've prepared a fix and new test that covers this case, but I'd like #23 to be merged before I open a PR for this issue, if you don't mind.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

Yes