离线使用 Backbone.js

发布于 2024-10-14 17:31:30 字数 432 浏览 8 评论 0原文

我正在评估 Backbone.js 在我的 Web 应用程序中保持数据和 UI 同步。然而,Backbone 的大部分价值似乎在于它对 RESTful 接口的使用。尽管我将来可能会添加服务器端备份,但我的主要用例涉及使用 HTML5 本地存储离线存储所有数据。

对于这样的用例来说,Backbone 是否太过分了?如果是这样,是否有更好的解决方案,只专注于数据更改时更新 UI,反之亦然? (我也在研究 Knockout 和 Javascript MVC。)

编辑:我现在也在研究 Angular.jsjQuery 数据链接

I'm evaluating Backbone.js for keeping data and UI synchronized in my web app. However, much of Backbone's value seems to lie in its use of RESTful interfaces. Though I may add server-side backup in the future, my primary use case involves storing all data offline using HTML5 local storage.

Is Backbone overkill for such a use case? If so, is there a better solution, focused solely on updating UI when data changes, and vice versa? (I'm also looking into Knockout and Javascript MVC.)

EDIT: I'm also now looking into Angular.js and jQuery Data Link.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冬天旳寂寞 2024-10-21 17:31:30

Backbone.js 与本地存储的配合与 RESTful 查询的配合一样好。

我是一个通过示例学习的人,所以这里有一些帮助您入门的链接:

Backbone.js works just as well with local storage as it does with RESTful queries.

I'm a learn-by-example kind of guy so here are some links to get you started:

中二柚 2024-10-21 17:31:30

在过去的几周里,我针对与您的情况接近的情况评估了不同的解决方案;作为一个在我个人空闲时间完成的项目,而不是一个优秀的 Javascript 程序员,我所需要的只是一些易于学习的东西,以避免从头开始。

毫不奇怪,我有相同的候选者:Backbone.js、Javascript MVC 和 Knockout.js。

Backbone.js 获胜:

  • 我不需要遵循约定或替换已经存在的内容
  • 我可以轻松地侵入其代码库以了解文档中不清楚的内容
  • 我成功地忽略了它的大量功能这对我来说并不有趣
  • 它在繁忙的页面上提供了可接受的性能
  • 它可以工作

Backbone.js 是轻量级的并且相对没有魔法;您可能会使用其功能的一小部分,但它为开发您的解决方案提供了坚实的基础。

In the past weeks I have evaluated different solution for a scenario close to yours; being a project done in my personal free time and not being a good Javascript programmer, all I needed was something easy to learn to avoid starting from scratch.

Not surprisingly, I had the same candidate: Backbone.js, Javascript MVC and Knockout.js.

Backbone.js won:

  • I wasn't be required to follow conventions or replace what was already in place
  • I've easly hacked in its codebase to understand what wasn't clear from the documentation
  • I've successfully ignored a large amount of its features that was not interesting for me
  • It gave acceptable performance on busy pages
  • It works

Backbone.js is lightweight and relatively magic-free; you will probably use a small subset of its feature but it provieds a solid base to develop your solution.

遮云壑 2024-10-21 17:31:30

我知道已经有一段时间了,但您可能想查看 github 上的骨干离线项目: https://github .com/Ask11/backbone.offline

I know it's been a while but you may want to check out backbone-offline project on github: https://github.com/Ask11/backbone.offline

我的鱼塘能养鲲 2024-10-21 17:31:30

您还可以查看 AFrameJS。我创建了一个简单的概念证明笔记应用,可以离线使用使用 HTML5 WebSQL 规范,但还想创建一个也使用 localStorage 的适配器。我个人的观点(我有偏见)是,从长远来看,使用任何类型的 MVC 库都会对您有所帮助 - Backbone、Knockout 和 AFrame 等库的价值在于它们能够减少 MVC 的认知负担开发人员通过强制实施良好的关注点分离。数据相关的功能驻留在模型中,显示数据驻留在视图中,而粘合剂则保留在控制器中。乍一看,分离这三个概念可能看起来很迂腐,但最终的结果是代码更容易开发、更容易测试、更容易维护、更容易重用。有关使用 AFrameJS 的基本教程可以在我的网站上找到:http:// www.shanetomlinson.com/2011/aframejs-tutorial-for-noobs/

You can also take a look at AFrameJS. I have created a bare-bones proof of concept note-taking app that works offline using HTML5 WebSQL spec, but also want to create an adapter that uses localStorage as well. My personal opinion (and I am biased) is that using an MVC library of any sorts is going to help you in the long run - the value of libraries such as Backbone, Knockout, and AFrame lie in their ability to reduce the cognitive load of the developer by enforcing a good separation of concerns. Data related functionality reside in models, displaying that data resides in Views, and the glue is kept in Controllers. Separating these three concepts might seem pedantic at first, but the end result is code that is easier to develop, easier to test, easier to maintain, and easier to reuse. A basic tutorial on using AFrameJS can be found on my site at: http://www.shanetomlinson.com/2011/aframejs-tutorial-for-noobs/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文