Just calling out to the greater community here to see what you think is the best way to subscribe to data in my app I am building. Let me explain what the app does and how it works.
Very simple app for tracking the value of a users share portfolio.
Build using react for the UI.
Users build their portfolio by adding the actual trades they have made, the app does the rest.
There are a number of collections (not including the user and standard collections):
- Update collection, which is like a news feed for the app.
- Portfolio collection, users currently only have one, but in the future may have more.
- Trade collection, these are all the trades linked to the users portfolio
- Stock collection, this is a collection of all the stocks being tracked across the portfolios, it contains most recent share price etc…
- Dividend collection, collection of all the dividend payments for all the tracked stocks
Originally I had it so that the main layout component triggers a subscription to the user portfolio and all their trades.
On the news page another subscription was kicked off for all the update feed.
On the portfolio information page another subscription was kicked off for all the stock and dividend information.
This means that changing pages meant waiting for subscriptions to sync.
I’ve since updated the app and now I make one subscription call to get all the information: Updates, Portfolio, Trades, Stock and Dividend information… This subscription runs once, and is only called again when the user updates their portfolio (needs to do this because the Stock and Dividend publication limits what it shares to only the relevant stocks from the users portfolio, so adding a new stock needs to update the subscription).
I have found this to make the app perform much better as all the information is at hand immediately without waiting for subscriptions. With the previous method, I watched my Kadia:Debug and it was constantly subscribing and dropping when changing pages. I know it means each subscription is pretty much completely custom, but that’s the nature of the app…
Are there any major downsides to doing this?
Does anyone have any other suggestions?
@arunoda - any thoughts on this? My decisions here are largely because of what I saw in Debug and Kadira UI.