TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Making Flux and REST Play Nicely Together

20 pointsby chanindover 10 years ago

2 comments

andwaalover 10 years ago
I am not sure if I get the point of the ServerModels. One would need to maintain the properties in both the ViewModel and the ServerModel, write logic for syncing them and so on. It also goes against the principle of &quot;one-true-source&quot; of data. I can see that you don`t want to mix up your view-specific properties with your rest-data, but I feel that one might find a better solution for this problem.<p>On the application I am currently working on we choose the following approach to the problem( were using reflux for Flux implementations, main difference is that actions dispatches them self).<p>View -&gt; Trigger Action -&gt; Action Creator -&gt; Action creator calls Rest API -&gt; Action sent to Store -&gt; Store receives REST data and creates Immutable versions of it -&gt; Store Triggers immutable version of it`s content to view<p>This keeps the stores as the &quot;one-true-source&quot; while the action creators does all the communications against the rest-api. Might be that this approach will be to simple when the application is starting to really expand, but I feel we found an easy to maintain, easy to understand and clean solution to the problem.
评论 #8964552 未加载
daveidolover 10 years ago
I would really love to see some code snippets with the example mentioned (or ideally an open source project).
评论 #8955195 未加载