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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

A view’s responsibility — a lesson on JavaScript and the DOM

70 点作者 kjbekkelund大约 13 年前

5 条评论

kjbekkelund大约 13 年前
The blog appears to be down. You can also read it at <a href="https://github.com/kjbekkelund/writings/blob/master/published/views.md" rel="nofollow">https://github.com/kjbekkelund/writings/blob/master/publishe...</a> (I'm the author)<p>Edit: The blog appears to be up again! Hopefully it'll stay up this time ;)
评论 #3923356 未加载
alinajaf大约 13 年前
Agree with this on multiple levels, though in practice I find a lot of codebases where views directly call events on passed-in model objects. In simple applications I find the extra level of indirection isn't worth it.<p>I put together some similar thoughts on client side code organization a while back: <a href="http://happybearsoftware.com/client-side-field-notes.html" rel="nofollow">http://happybearsoftware.com/client-side-field-notes.html</a>
VeejayRampay大约 13 年前
I've always wondered why it wasn't possible to send a message to an object directly in Javascript. Here, you need to emit the message for EventEmitter to relay it back to the receiver. Though I guess there are benefits to this model as well, like a more centralized control of the whole flow of execution, possible message translations and composition.
mattbriggs大约 13 年前
I came to the same conclusion awhile back. Also, if it is in any way possible, a view should be able to write its own HTML (the rails worl has a concept of JSTs, not sure if that has filtered out yet), and a view should never insert itself into the dom<p>What you get is loosely coupled, highly testable (and fast tests, since dom stuff is all in memory) ui code.
评论 #3923696 未加载
chris_wot大约 13 年前
Is the code meant to have entity characters encodings showing through? Love the post though - very thought provoking!
评论 #3924348 未加载