meteor-flux-leaderboard
meteor-flux-leaderboard copied to clipboard
Best place to put Subscriptions and Fetchings on Redux?
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
Place of Subscription OK. But where to put trackCollection?
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
Thanks Adam, Subscription place is important, if subscribed then tracked anyway.