TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Implementing the Elm Architecture in Swift

93 点作者 rheeseyb超过 9 年前

4 条评论

jawngee超过 9 年前
As someone who writes some pretty hardcore UIs in Cocoa, this reactive style stuff seems applicable to a pretty narrow class of application.<p>The more you fight Cocoa, which I believe this stuff does, the bigger the mess you&#x27;ll create for yourself once you view hierarchy becomes large and filled with custom views that don&#x27;t really fit what 99% of these tutorials cover.<p>Furthermore, trying emulate &quot;dom&quot; diffing by replacing views, instead of updating them, as they seem to be illustrating towards the end of the article (could be reading this wrong though) is pretty inefficient way of doing things in Cocoa.
评论 #11019420 未加载
评论 #11018813 未加载
评论 #11019559 未加载
评论 #11018821 未加载
shoover超过 9 年前
Interesting times for experimental Swift UI libraries coming out, with tcp-json-swift [1] mentioned last week and now this.<p>This is an excellent synthesis and transfer of related technology. Nice work! Some of the Swift- and NS-isms are tricky to follow without knowing Mac dev, and I&#x27;m still wrapping my head around how it all wires together, but especially the update loop is very clear and small and I think a unique use of Rx to blend into React&#x2F;virtual-dom&#x2F;Elm ideas.<p>My perspective is I am trying to bring the Elm Architecture to F# but started out porting virtual-dom.js on the bottom. It&#x27;s early and ugly and just at the point of having to deal with patching children nodes, so parts of this are quite relevant. One avenue I intend to check out is performing set operations on a flat node list and using something like protocol methods on parent views to add and remove children, so that part of the code is definitely going to trigger some thoughts.<p>The dictionary of observables indexed by node threw me at first. AFAICT the virtual views, action types, and updates all compose, and then once it&#x27;s time to do anything with real views (the patch operation in diff&#x2F;patch terms) just that part is handled independently per node? (EDIT: Ah, I see the context dispatch is composed as in Elm, and only pushing down model updates is separate.) It&#x27;s dead easy compared to the work virtual-dom.js has to do to index patches, index DOM nodes, and walk the DOM applying updates. This seems to handle all that with much less code, with a couple caveats:<p>1) The ability to reorder children is missing, right?<p>2) Any plan to support laziness to curb rerendering sections of the virtual tree? It&#x27;s probably not needed for many apps, but for some reason the feature gets air time in discussions around React and Elm. (Looks like all observables get called unconditionally once per update, too?)<p>[1] - <a href="https:&#x2F;&#x2F;github.com&#x2F;chriseidhof&#x2F;tcp-json-swift" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chriseidhof&#x2F;tcp-json-swift</a>
评论 #11025640 未加载
rheeseyb超过 9 年前
Open sourced here: <a href="https:&#x2F;&#x2F;github.com&#x2F;momentumworks&#x2F;swift-elm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;momentumworks&#x2F;swift-elm</a>
phatbyte超过 9 年前
As someone who&#x27;s currently learning Swift and Cocoa and have no idea what Elm is. Is this something actually useful that helps building apps?
评论 #11021473 未加载
评论 #11020984 未加载
评论 #11019744 未加载