AdamBrodzinski / meteor-flux-leaderboard

Flux Example with React & Meteor
131 stars 19 forks source link

Best place to put Subscriptions and Fetchings on Redux? #8

Open SenerDemiral opened 9 years ago

AdamBrodzinski commented 9 years ago

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

SenerDemiral commented 9 years ago

Place of Subscription OK. But where to put trackCollection?

AdamBrodzinski commented 9 years ago

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

SenerDemiral commented 9 years ago

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