Skip to content

Feature request for a notify middleware: Prevent notifying all listeners in certain conditions #2445

@zeachco

Description

@zeachco

Hi, this is a feature request

What is the current behavior?
Every dispatch cause all listeners to be called without the possibility to prevent it.

The "hackish" to do it would be with the enhancer function from createStore. I don't find this clean for the following reason:
It require to rewrite createStore completely which make me wonder why do we require Redux in the first place if it's to pass a function that replace it completely.

What is the expected behavior?
I think allowing to pass a middleware would be helpfull for cases such as Redux used with Immutable.js. A middleware could verify that the state has muted and not call uselessly all the listeners if not. Other usecase could also apply such as "locking" dispatch in certain conditions for other performances reasons.

I think the goal of Redux is to notify the state changes, not to notify that a dispatch happen otherwise his role wouldn't be to hold a store a well but more a simple event bus system. Maybe I didn't get correctly the misson of Redux here so let me know if I'm in the wrong here.


The current Redux version is 3.6.0
this applies for all browsers / node environments and all OS


I currently have a working version of this which need polishing so I would provide the PR if this feature is accepted.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions