Skip to content

Strange behavior when passing action function into store.dispatch #1906

@SerkanSipahi

Description

@SerkanSipahi

Minimal reproduction of the bug/regression with instructions:

I called someAction (see below simple example code) without function call "()" when it passed to store.dipatch(....)! The problem, it has not become an error. The action even arrived the reducer. Unfortunately it was not logged in the ReduxDevTools (it freezed, all other actions e.g. router will be ignored in the ReduxDevTools). Only with a MetaReducer logger I see what happens. After I called closeMainSidebarAction() with "()" the ReduxDevTools worked again.

We should prevent this behavior by throwing an error.

That was really frustrating! I think it took me more than 2 hours to realize that I forgot to call the function call. I think that the potential is high that another one will run into this strange behavior.

I will create a PR for it!

Code Example:

const someAction = createAction('Some Action');
store.dispatch(closeMainSidebarAction);

Expected behavior:

It should throw an error that to pass a function into dispatch is not allwed?

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

ngrx v8 rc0

Other information:

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

[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions