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

Avoid run all the subscription flow for components not passing mapStateToProps as argument #4

Open
mariosanchez opened this issue Oct 11, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@mariosanchez
Copy link
Collaborator

mariosanchez commented Oct 11, 2019

In some edge cases we are using subscribe function only to inject props, yet not for subscribing it to the state. In those cases we aren't passing by mapStateToProps.

Despite we consider it an anti-pattern, because we could simply compose the component in order to achieve that, it will be a improvement to not execute all the subscription flow if no mapStateToProps is passed by in the subscribe function.

Now we are passing by an empty fucntion:

subscribe(Component, () => {}, { myInjectedPropr: 'Hi there' });

This should allow to do this:

subscribe(Component, null, { myInjectedPropr: 'Hi there' }`);
@mariosanchez mariosanchez added the enhancement New feature or request label Oct 11, 2019
@trikitrok
Copy link
Collaborator

It's a nice idea.
If it were possible, I'd would prefer to have a function with two arities instead of passing a null though.

@alexhoma
Copy link
Member

alexhoma commented Oct 14, 2019

The main point of this would be to not execute the mapStateToProps if the component does not need to be subscribed to the state. But I can't imagine how to check this without executing the function and checking its returned values. With null will be easier to check it.
Anyway, I'd prefer to use null instead of () => {}. 😛

@alexhoma alexhoma changed the title Avoid run all the subscription flow for components not passsing mapStateToProps as argument Avoid run all the subscription flow for components not passing mapStateToProps as argument Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants