Skip to content

Support to observe the relevant actions only #1091

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

Closed
lnaie opened this issue Dec 2, 2015 · 4 comments
Closed

Support to observe the relevant actions only #1091

lnaie opened this issue Dec 2, 2015 · 4 comments

Comments

@lnaie
Copy link

lnaie commented Dec 2, 2015

Hi,

In current implementation, all the subscribers are notified when an action has been performed.
Any plans to support notification of the relevant subscribers only? The use-case would be: I would like to subscribe for the results of a particular action only. Or provide the dispatched action as a param in the subscription callback?

It may not be relevant to reactjs, but it will be useful to the other worlds.

Thanks

@just-boris
Copy link
Contributor

As you can see in the shopping-cart example, you can the following reducer:

function addedIds(state, action) {
  switch (action.type) {
    case ADD_TO_CART:
      return handleCartUpdate(state, action);
    default:
      return state
  }

There is a lot of different actions, but you can change state only on some of them. If you get an action, which is not interesting for you, just skip it and go to default section.

Does it help for you?

@lnaie
Copy link
Author

lnaie commented Dec 2, 2015

That is clear. is the reducer part of the flow.
The use-case being: In this particular page I would like to be notified only be the action x, it probably relates to the way subscribers are being handled, more exactly this part of dispatch():
listeners.slice().forEach(listener => listener()); return action

@just-boris
Copy link
Contributor

This is the main concept of Redux. Listeners shouldn't know about recent action.
Here already was a discussion in #622

If you want to handle specific action, just rely on result of that action, not the action itself

@lnaie
Copy link
Author

lnaie commented Dec 2, 2015

Did help. Thanks! :)

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

No branches or pull requests

3 participants