meteor-flux-leaderboard icon indicating copy to clipboard operation
meteor-flux-leaderboard copied to clipboard

Best place to put Subscriptions and Fetchings on Redux?

Open SenerDemiral opened this issue 9 years ago • 4 comments

SenerDemiral avatar Sep 05 '15 11:09 SenerDemiral

Do you mean where to put the subscribe call or the data that gets returned in mini-mongo? I presume the former, if not let me know.

I like to put the subscriptions in the topmost component of a feature... for example subscribe to the chats data in ChatsContainer and in this container use connect to get the data from state. The only other thing ChatsContainer does is render one child, Chats and it sends it's properties down to it. This makes it like a view-controller that only handles data. This makes Chats really easy to test and debug.

Here's an example of this method: https://github.com/AdamBrodzinski/meteor-flux-leaderboard/blob/redux/client/components/AppContainer.jsx#L7

AdamBrodzinski avatar Sep 05 '15 21:09 AdamBrodzinski

Place of Subscription OK. But where to put trackCollection?

SenerDemiral avatar Sep 06 '15 10:09 SenerDemiral

Ah, I've been putting trackCollection a line after defining the collection so it's easy to find/notice. It can really go anywhere as long as the collection is defined, but putting it close makes it easy for me to find.

Cheers Adam

AdamBrodzinski avatar Sep 06 '15 17:09 AdamBrodzinski

Thanks Adam, Subscription place is important, if subscribed then tracked anyway.

SenerDemiral avatar Sep 06 '15 19:09 SenerDemiral