U
U
unkwua2015-07-31 15:16:48
JavaScript
unkwua, 2015-07-31 15:16:48

Reflux: how to use store correctly?

There is postsBoardStore
Here is the jsx:

<Discussion><postsList /><postsBoard /></Discussion>
     <Discussion><postsList /><postsBoard /></Discussion>

For example, inside the postsList component I call the togglePostsBoard action, inside postsBoard I listen to changes in the postsBoardStore and everything seems to be fine, but the problem is that all the postsBoards that are on the page listen to the postsBoardStore, and in this case I need only one to listen. How to solve a similar problem? There is a crutch, as for me, a trick to pass the discussionId when calling the action, but for this, in the postsBoard, you also need to pass the id of the discussion and filter when the postsBoardStore changes. In such cases, the store is not needed at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Goryachkin, 2015-07-31
@unkwua

It is possible without stora, but this is no longer flux. And what are your problems when using one storage?. Mark each component when it is initialized with some identifier. Remember it in the component itself and mark the component in the Store with the same key, but yes, with each change, you will have to pass this key as well in order to identify which component the change occurred in. In fact, if the component has a narrow specialization and the application itself is small, then I would score on the storage and process all its changes inside the component. But here, as they say, choose what your soul lies more in, if you do it through the Store, then you will also have flux - the architecture and access to the states of all the postsBoard components, but you will need to write more. If without Store, then writing is less and easier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question