Thank you for reporting this bug. We will make it our priority to review this report.
[5.0.1.1255] Broken Proxy "Listeners" within ViewModel Stores
[5.0.1.1255] Broken Proxy "Listeners" within ViewModel Stores
STAND-ALONE TEST CASE
Fiddle: http://ift.tt/12jYq1jADDITIONAL INFO
Ext version tested:
Browser versions tested against: DOCTYPE tested against: Description:- When using an MVVM-architecture, proxies created within ViewModels do not use the associated ViewController as the context for assigning listeners via the proxies' "listeners" attributes.
Steps to reproduce the problem:- Create a View with an associated ViewModel and ViewController.
- Add a store with a proxy to the ViewModel.
- Assign a listener to the ViewModel store with an associated function in the ViewController (assign by name). Example: listeners: {beforeload: "onStoreBeforeLoad"}
- Assign a listener to the ViewModel store proxy with an associated function in the ViewController (assign by name). Example: listeners: {exception: "onProxyException"}
- Perform an event that would trigger the listening function on the store.
- Perform an event that would trigger the listening function on the proxy.
The result that was expected:- The store event function within the ViewController should trigger.
- The proxy event function within the ViewController should trigger.
The result that occurs instead:- The store event function within the ViewController does trigger (as expected).
- The proxy event function within the ViewController does not trigger and an exception is thrown saying that no function by the given name exists within the context of the proxy's class. It should be looking for an instance of the function within the context of the view controller's instance instead, just as the store does.
WORKAROUND
Assign the function explicitly within the proxy's "listeners" attribute. Unfortunately, this is not possible in Sencha Architect 3.1 without using a "Process Config" function and also does not follow the architecture pattern.Another workaround is to add the listener to the proxy from within the ViewController "init" function. Unfortunately this has to be deferred since the ViewModel stores aren't instantiated by the time the ViewController's init is called, so then you're rolling the dice to find a defer delay that will trigger after the ViewModel stores are instantiated but before the proxy event is fired.
OTHER NOTES
In Sencha Architect 3.1, the View Controller Event Binding attribute on proxies creates listeners as described here and will lead to this exception when used. If this is not a bug with Ext JS then please move this to the Architect bugs forum.Also, the "Submit Item" button in the Fiddle adds an item to the store which has "autoSync" set to true, but for some reason it does not attempt to sync the first time that an item is added. Does anybody know why?
FIDDLE
[5.0.1.1255] Broken Proxy "Listeners" within ViewModel Stores
Aucun commentaire:
Enregistrer un commentaire