JavaScript Assigning a reducer for a dynamic store property

I'm trying to figure out how to set up a reducer for a property in my state tree that gets created from user events.

My state tree looks like this:

{
  session: { session object },
  dashboard: {
    id: 'id001',
    charts: {
      'cid001': { dimensions: { ... }, more objects... },
      'cid002': { dimensions: { ... }, more objects... }
    }

  } 
}

New charts properties come in through Redux when a user clicks the Add Chart button. The key is set to the chart id, cid.

I'm currently using combineReducers() to set up the reducer tree.

import session from './session';
import charts from './charts';

const rootReducer = combineReducers({
  session,
  dashboard: combineReducers({
    charts
  });
});

I am able to nest reducers like this if I know the property names ahead of time. However, I'd like to avoid having a massive reducer for the charts property, since each chart inside it could have up to 20 more objects on it that need reducing, dimensions is just one example.

Is there a way to set a reducer for the charts['cidxxx'].dimensions, and other sub-properties? Are there wildcard tokens for this? Any thoughts?

Answer:1

I'm trying to hide the "collapsible" button after it is being pressed. activities.html: <button class="collapsible"> <i class="fa fa-angle-down"></i></a></button> ...

I'm trying to hide the "collapsible" button after it is being pressed. activities.html: <button class="collapsible"> <i class="fa fa-angle-down"></i></a></button> ...

  1. hiding button after collapse is toggle in bootstrap

Jest has this feature to log the line that outputs to console methods. In some cases, this can become annoying: console.log _modules/log.js:37 ℹ login.0 screenshot start console.time _modules/...

Jest has this feature to log the line that outputs to console methods. In some cases, this can become annoying: console.log _modules/log.js:37 ℹ login.0 screenshot start console.time _modules/...

How could I change selected option for dropdown list using javascript or jQuery? <select id ="someId" name="someName"> <option>One</option> <option>Two</...

How could I change selected option for dropdown list using javascript or jQuery? <select id ="someId" name="someName"> <option>One</option> <option>Two</...

  1. selected option using jquery
  2. selected option using javascript
  3. selected option using angularjs
  4. set selected option using jquery
  5. get selected option using jquery
  6. change selected option using jquery
  7. get selected option using javascript
  8. set selected option using javascript
  9. change selected option using javascript
  10. show selected option using jquery
  11. get selected option using js
  12. remove selected option using jquery
  13. find selected option using jquery
  14. selected option value using php
  15. selected option value using jquery
  16. make option selected using jquery
  17. jquery set selected option using value
  18. jquery set selected option using index
  19. jquery get selected option using id
  20. get selected option value using jquery

I have these two strings: "1-2" and "1--2". I would like to have a regex that would match only the first occurrence of the hyphen in both strings, such that the split would then be: [1,2] and [1,-2]. ...

I have these two strings: "1-2" and "1--2". I would like to have a regex that would match only the first occurrence of the hyphen in both strings, such that the split would then be: [1,2] and [1,-2]. ...

  1. regex matching only numbers
  2. regex matching only letters
  3. regex matches only once
  4. regex matches only
  5. regex only matching first
  6. regex only matching last
  7. regex only matching first character
  8. regex unique matches only
  9. grep regex only matching
  10. regex return only matching string
  11. perl regex only matching