简体   繁体   English

BackboneJS中的集合用法

[英]Collection usage in BackboneJS

Which is better to use the collection: 使用该集合哪个更好:

  1. Collection contain the total list of data, and include a function to select the the part of data show in view. 集合包含总数据列表,并包含一个函数来选择视图中显示的数据部分。 Lots of data should be loaded in client side. 应该在客户端加载大量数据。

  2. Collection only contain the data to show in view. 集合仅包含要在视图中显示的数据。 In this way, require to fetch data from server more frequently. 这样,需要更频繁地从服务器获取数据。 And the data to show in view is selected on server side. 并且在服务器端选择要在视图中显示的数据。

Any suggestion? 有什么建议吗?

It depends on the size and sensitivity of the collection, but in general I preference proxying requests to the server-side, and storing only the view/cache data locally. 它取决于集合的大小和敏感性,但通常我优先将请求代理到服务器端,并在本地仅存储视图/缓存数据。 It will serve better in the long-run. 从长远来看,它将更好地发挥作用。

如果您有大量数据,最佳解决方案是按需加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM