tl;dr: I wonder if having lots (100+ for the moment, potentially up to 1000/2000 or more) of backbone views (as a cell of a table) is too heavy or not

tl; dr:我想知道是否有很多(目前100+,可能高达1000/2000或更多)骨干视图(作为一个表格的单元格)太重或不

The project I'm working on revolves around a planning view. There one row per user that covers 6 hours of a day, each hour splitted in 4 slots of 15mn. This planning is used to add "reservations" when clicking on a slot, and should handle hovering of the correct slots, and also handle when it is NOT possible to make a reservation - ie. prevent user click on an "unavailable" slot.

我正在研究的项目围绕着一个规划视图。每个用户一行,每天6小时,每小时分为4个15分钟。此计划用于在单击插槽时添加“预留”,并应处理正确插槽的悬停,并且还可以在无法进行预订时进行处理 - 即。阻止用户点击“不可用”的插槽。

There is many reasons why a slot can't be clicked on: the user is not available at this time, or the user is in a reservation; or the app needs to "force" a delay slot between two reservations. Reservations (a div) are rendered in a slot (a cell of a table), and by toying with dimensions, hovers the right number of slots.

无法单击插槽的原因有很多:此时用户不可用,或者用户正在预订中;或应用程序需要“强制”两个预订之间的延迟槽。预留(div)在一个槽(表格的一个单元格)中呈现,并通过使用维度进行操作,悬停正确数量的槽。

All this screen is handled with backbone. So For each slot I'm hovering on, I need to check wether I can do a reservation here or not. As of this moment, I use this by toying with the data attributes on the slots : when a reservation object is added, the slots covered are "enhanced with (among others) the reservation object (the backbone view object).

所有这些屏幕都由骨干处理。因此,对于我正在徘徊的每个插槽,我需要检查是否可以在此处进行预订。到目前为止,我通过使用插槽上的数据属性来使用它:当添加预留对象时,所覆盖的插槽“由(以及其他)预留对象(骨干视图对象)增强。

But in some cases I don't quite have a grasp on now, it mixes up, and when the reservation view is removed, the slots are not "cleaned up" : the previous class is not reset correctly. It is probably something I've done wrong or badly, but this is only going to get heavier; I think I should use another class of Backbone views here, but I'm afraid the number of slots and thereof of views objects will be high and cause performance issue. I don't know mush about js perf so I'd like to have some feedback before jumping on that train. Any other advice on how to do this would be quite welcomed too.

但在某些情况下,我现在还没有完全掌握,它会混淆,当删除预订视图时,插槽不会“清理”:前一个类没有正确重置。这可能是我做错了或做得不好的事情,但这只会变得更重;我想我应该在这里使用另一类Backbone视图,但我担心视图对象的插槽数量会很高并导致性能问题。我不知道有关js perf的消息,所以我想在跳上那列火车之前得到一些反馈。关于如何做到这一点的任何其他建议也会受到欢迎。

Thanks for your time. If this is not clear enough, tell me, I'll try and rephrase it.

谢谢你的时间。如果这还不够清楚,请告诉我,我会尝试改写它。

3 个解决方案

#1


7

We have a pretty complex backbone.js app with potentially thousands of views at a given time. Our bottlenecks are mostly in memory leaks from views that have not been properly removed or eventdriven rendering that re-renders views needlessly. That said, the actual number of views doesn't seem to affect much. Backbone views are pretty lightweight, so as long as you don't have too much events bound to them, it's not that big of a problem.

我们有一个非常复杂的backbone.js应用程序,在给定时间可能有数千个视图。我们的瓶颈主要是来自未正确删除的视图的内存泄漏,或者事件驱动呈现不必要地重新呈现视图。也就是说,实际的观看次数似乎并没有太大影响。骨干视图非常轻量级,所以只要你没有太多的事件绑定到它们,它就不是那么大的问题了。

You might run into performance issues, but the views probably isn't the problem.

您可能遇到性能问题,但视图可能不是问题。

What you might want to do though, if you do use thousands of views is to stash up the initial rendering into one big ´.html()´-call. You can do this by giving each view-element an id based on the view's cid and then you concatenate the view's html strings and afterwards you use setElement on each view to find its element again.

你可能想要做的事情,如果你确实使用了数千个视图,那就是将初始渲染存储到一个大的'。()'调用中。您可以通过基于视图的cid为每个view-element提供一个id,然后连接视图的html字符串,然后在每个视图上使用setElement再次查找其元素。

更多相关文章

  1. 在用户将'n'粘贴复制到文本字段后,如何更新视图模型?
  2. 在项目之间共享ASP.NET MVC部分视图
  3. 如果外部应用程序更改了持久模型(服务器数据库),AngularJS可以自
  4. 如何在rails中使用ajax将数据从控制器传递到视图
  5. 从json获取最大插槽并应用于控制器
  6. django的视图和URL配置
  7. Python Flask WTForms:如何在视图中动态禁用字段?
  8. Django反向url与参数到基于类的视图
  9. 从django视图中的按钮获取click事件

随机推荐

  1. 分布式作业系统 Elastic-Job-Lite 源码分
  2. IP地址与子网的作用和组成
  3. java 中 String s = "" 与 new String()
  4. 子网掩码的进制转换
  5. vtp实验
  6. 共享文件夹
  7. 华为ensp链路聚合综合实验
  8. Kafka 原理以及分区分配策略剖析
  9. 单臂路由
  10. 说话时如何把“NO”变成“yes”?