Method in ThreadStore instead of UnreadThreadStore
Hi! I'm wondering why a new store has been created to provide the views a count of unread threads on flux-chat example.
Wouldn't it be better if we had a getUnreadCount method in the ThreadStore? If I had to count archived threads, would it be better to create a ArchivedThreadStore?
Thanks in advance ;)
Mainly because we were trying to create an example where we could show waitFor(). The example is a bit forced.
Got it. It made me confused on the role of stores in Flux, wondering if I would need that level of abstraction. Maybe we should update the flux-chat example to avoid this. If you agree, I can spend some time thinking about an alternative.
The getCount() function recomputes its value every time it is called. It could instead recompute it after receiving actions that indicate that the result may have changed. It would store the cached value and getCount() would just return it.
BTW is it expected that a derived store like UnreadThreadStore has to know which specific actions will cause ThreadStore to modify the results of getAll()? It feels like it has knowledge of the internals of the store it is reading from.
Where a store is computing "derived" data like this, is it possible that it would also respond to actions to mutate the data? Is there a realistic example of that? It sounds like it would result in inconsistency.
+1 for finding an appropriate example of waitFor rather than forcing the contrived example
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.