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

Benefits of k-redux-factory selectors #158

Open
delphinemillet opened this issue Jan 2, 2019 · 2 comments
Open

Benefits of k-redux-factory selectors #158

delphinemillet opened this issue Jan 2, 2019 · 2 comments
Labels

Comments

@delphinemillet
Copy link

Sometimes, accessing an object in the state from a container is quickier to write than using its selector.
I would like to know all the advantages of k-redux-factory selectors over the direct use the state.

@fabienjuif fabienjuif self-assigned this Jan 2, 2019
@fabienjuif
Copy link
Member

fabienjuif commented Jan 2, 2019

k-redux-factory is a lib that aim to access your data as fast as possible.
By using selectors you are safe about our possible internal state restructurations.

For example, we move from keyValue like that:

  • { keys: [], array: [], data: {}, initialized: false }
    to
  • { data: [[]], initialized: false }

In this example if you didn't use our selectors, an upgrade of k-redux-factory could break your application. But if you used our selectors, it wouldn't.

Always prefers using lib API and not its internals, when you can!


Besides that I see these advantages:

  1. We (k-redux-factory) can refactor our code without breaking your application (see previous comment)
  2. You have a standard, always use selectors
  3. You can move your factory around your store definition -> your containers will not have to be fixed
  4. You can memoize selectors if you need to at some point

@fabienjuif
Copy link
Member

moreover, if you want to try k-ramel, you can access the state using k-redux-factory selectors in a quick way:

export default inject(store => ({
  users: store.data.users.get(),
})(Component)

https://github.com/alakarteio/k-ramel

@fabienjuif fabienjuif removed their assignment Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants