javascript - Flux architectures nested and non-singleton stores -


i data on page load , json looks follows:

{   users: [     {       userid: 1,       messages: [         {           messageid: 1,           lines: [/* array of lines */]         },         {           messageid: 2,           lines: [/* array of lines */]         }                 ],     },     {       userid: 2,       messages: [         {           messageid: 3,           lines: [/* array of lines */]         },         {           messageid: 4,           lines: [/* array of lines */]         }                 ],     },   ] } 

as example of problem, i'm trying implement message selection feature. each user can have 1 message selected @ time. when call action creator selectmessage(messageid) , gets passed down messagesstore, how know user should have message selected?

the option see pass userid down view hierarchy , add action creator - handling action in usersstore rather in messagesstore. thinking architecture wrong?

the choice of store save depends on how choose relate stores components. take approach each component should have own store. (i don't). others try treat stores resources (as in rest). sounds that's you're learning to?

that can work, too, have found fundamental idea of resources (as expressed in restful architectures) artificial , limiting. prefer think of stores collections of related data without strong structural cohesion of resource.

that's rather long-winded way of saying think either approach you've outlined fine. question try ask myself this: later, when application becomes larger, obvious store hold particular bit of data?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -