简体   繁体   English

ExtJS Ext.state.Manager.setProvider()在6.2和4.x中的行为

[英]ExtJS Ext.state.Manager.setProvider() behavior in 6.2 vs 4.x

I have an existing ExtJS application I'm upgrading from 4.x to 6.2.0. 我有一个现有的ExtJS应用程序,正在从4.x升级到6.2.0。 I had a simple storage provider setter that I pass into my Ext.onReady() block that looks like the following: 我有一个简单的存储提供程序二传手,我将其传递到Ext.onReady()块中,如下所示:

Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider',{}));

When I swapped to 6.2.0, I'd get the error: 当我换成6.2.0时,会收到错误消息:

ext-all-rtl-debug.js:9389 [E] Ext.util.LocalStorage.constructor(): Cannot create duplicate instance of local store "ext". Use Ext.util.LocalStorage.get() to share instances.

So what I had to do to, what I think is a fix, was the following: 因此,我要做的是以下事情:

Ext.state.Manager.setProvider(Ext.util.LocalStorage.get('id'));

My concern here though is that I'm just applying a bandaid to the problem and not really going through with a real fix. 我在这里的担心是,我只是对问题应用创可贴,而没有真正解决问题。 I don't explicitly set the provider anywhere else, all I did was swap out the ExtJS lib from 4.x to 6.2.0 to get that error. 我没有在其他任何地方显式设置提供程序,我所做的就是将ExtJS lib从4.x换到6.2.0来获取该错误。 It's as-if it's being created somewhere else first in the 6.2.0 initialization process and now I'm getting a duplicate error as aforementioned. 就像在6.2.0初始化过程中首先在其他地方创建它一样,现在我遇到了如上所述的duplicate错误。

What has changed in 6.2.0 to cause this behavior? 6.2.0中发生了什么更改以导致此行为? Is there now two providers set, one by ExtJS and one with my client code? 现在是否设置了两个提供程序,一个由ExtJS提供,另一个由我的客户代码提供? Is there a cleaner way of handling this? 有没有更清洁的方式来处理此问题?

The preconditions for this error are the same in both, ExtJS 4 and ExtJS 6. The corresponding file does not have changed: compare ExtJS 4.2.4 version and ExtJS 6.2.0 version . 在ExtJS 4和ExtJS 6中,此错误的前提相同。相应的文件没有更改:比较ExtJS 4.2.4版本ExtJS 6.2.0版本

Because of this your application must be responsible for this. 因此,您的应用程序必须对此负责。 Somewhere in your (upgraded) code an instance of Ext.util.LocalStorage must be created. 必须在您的(升级的)代码中的某个地方创建一个Ext.util.LocalStorage实例。 Since this error is thrown in case the ID is already registered and the registration is done only in the constructor of the Ext.util.LocalStorage class, I'd suggest to set a breakpoint right there to check in the stacktrace which function does call the constructor method. 由于如果ID已被注册并且仅在Ext.util.LocalStorage类的构造函数中完成注册,则抛出此错误,因此建议在Ext.util.LocalStorage设置一个断点以检查stacktrace哪个函数调用了构造方法。

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

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