简体   繁体   English

什么时候开始使用VueX商店?

[英]When to start using a VueX store?

I asked this question a while back and got a general overview of what a store does and a basic explanation as to why it is used. 不久前,我问了这个问题,并大致了解了商店的运作方式以及使用原因的基本说明。

However, I'm developing a web app for my company at the moment, and I'm running into some compute issues. 但是,目前我正在为我的公司开发一个Web应用程序,并且遇到了一些计算问题。

So firstly, I have about 35 data vars. 所以首先,我有大约35个数据变量。 Only a couple of them are used at a time, but larger ones hold 82,011 items in an array, another holds about 600. 一次只使用其中的几个,但较大的一个阵列可容纳82,011个项目,另一个则可容纳约600个项目。

Another array holds the contents of a CSV file, which can get up to 20,000. 另一个数组保存CSV文件的内容,最多可以存储20,000个文件。

I then have a function to compare the arrays by creating a hashmap of the contents from the CSV (so let's just say for example, it creates a hashmap of 20,000 key-value pairs) then runs each item in the 82K array through the hash map to find values that are the same, then moves them to a new array. 然后,我有一个通过从CSV创建内容的哈希图来比较数组的功能(例如,让我们说,它创建了20,000个键值对的哈希图),然后通过哈希图运行82K数组中的每个项目查找相同的值,然后将其移动到新数组。

TL;DR: I have a lot of data and a lot of computed functions, and Chrome ends up crashing somewhere along the line as its computing. TL; DR:我有很多数据和许多计算函数,Chrome最终在计算过程中崩溃了。 Do I need a store? 我需要一家商店吗? Or just a better way of computing stuff? 还是只是一种更好的计算方式?

First of all, I'll advice you move most of you business logic to the backend, as it has a more powerful infrastructure and is meant for that. 首先,我建议您将大多数业务逻辑转移到后端,因为它具有更强大的基础架构,并且为此而设计。

Do I need a store? 我需要一家商店吗?

You should switch to vuex for state management if your number of components is growing large, many sections of your code have to access the data stores(which might be changing) or you feel it's getting complicated to keep track of the app. 如果组件数量越来越大,代码的许多部分必须访问数据存储(可能正在更改),或者您觉得跟踪应用程序变得越来越复杂,则应该切换到vuex进行状态管理。

Or just a better way of computing stuff? 还是只是一种更好的计算方式?

This might be an algorithm-related issue so search for more efficient ways of calcutating. 这可能是与算法有关的问题,因此请寻找更有效的计算方法。

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

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