How to setup Ember like computed properties in Immutablejs and Redux and Flux and React

前端 未结 4 486
旧巷少年郎
旧巷少年郎 2021-01-05 01:11

I am used to computed properties in Ember Object Model. It\'s a convenient way to specify computed properties that depend on other properties.

Say fullName

4条回答
  •  我在风中等你
    2021-01-05 02:07

    Redux author here!

    Using reselect as suggested by WildService is the way to go. I think we won't include this in core because reselect does its job well and we're fine with it being a separate library.

    I wanted to note a couple of things:

    • Even with reselect, you don't want to compute data inside your reducer. Selectors should operate on the state managed by reducers. In other words, selectors are the step between your Redux store state and your components—they are not inside your reducers. It is essential you keep Redux state normalized so it's easy to update.

    • We actually encourage you to define selectors alongside the relevant reducers, so that when you change the state shape, you don't have to change your components—they would be using the selectors instead. You can see an example of this in the Redux folder of Flux Comparison

    • We have a documentation page introducing reselect and describing how to use it for computing derived data. Check it out.

提交回复
热议问题