flux icon indicating copy to clipboard operation
flux copied to clipboard

Method in ThreadStore instead of UnreadThreadStore

Open hugooliveirad opened this issue 11 years ago • 6 comments

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 ;)

hugooliveirad avatar Jan 20 '15 03:01 hugooliveirad

Mainly because we were trying to create an example where we could show waitFor(). The example is a bit forced.

fisherwebdev avatar Jan 20 '15 23:01 fisherwebdev

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.

hugooliveirad avatar Jan 21 '15 02:01 hugooliveirad

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.

danielearwicker avatar Mar 17 '15 19:03 danielearwicker

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.

danielearwicker avatar Mar 17 '15 19:03 danielearwicker

+1 for finding an appropriate example of waitFor rather than forcing the contrived example

ansonkao avatar Jun 20 '15 14:06 ansonkao

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.

ghost avatar Aug 05 '15 18:08 ghost