Skip to content

Instantly share code, notes, and snippets.

@rubystar
Last active July 4, 2017 08:08
Show Gist options
  • Save rubystar/5d7f32c62891f56d3f50394cc377e238 to your computer and use it in GitHub Desktop.
Save rubystar/5d7f32c62891f56d3f50394cc377e238 to your computer and use it in GitHub Desktop.
redux state structure
//Widgets
{
byId: {
1: {
settings:{name: 'report 1', description: 'report 1 desc'},
child_widget_ids: [10, 11]
},
2: {
settings:{name: 'report 2', description: 'report 2 desc'},
child_widget_ids: [12, 13]
},
11: {
foo: bar
},
12: {
} // and so on...
}
allIds: [1, 2, 11, 12, ...]
}
// in order to get a report from store
currWid = store.get("widgets").get("byId")(1)
// chart instances for the selected report
currWid.get("child_widgets_ids").map((item) => store.get("widgets").byId("item"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment