-
15 Dec 2011 12:36 PM #1
Proxy.js has Uses where it needs Requires
Proxy.js has Uses where it needs Requires
Because of this line in the constructor:
Ext.data.Model should move from the uses to the requires array, like so:Code:if (this.model !== undefined && !(this.model instanceof Ext.data.Model)) { this.setModel(this.model); }
Code:Ext.define('Ext.data.proxy.Proxy', { alias: 'proxy.proxy', alternateClassName: ['Ext.data.DataProxy', 'Ext.data.Proxy'], requires: [ 'Ext.data.reader.Json', 'Ext.data.writer.Json', 'Ext.data.Model' ], uses: [ 'Ext.data.Batch', 'Ext.data.Operation', //'Ext.data.Model' ],
-
15 Dec 2011 3:46 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
Can I get a test case where this is a problem?
Ext.data.Store has Ext.data.Model in the requires so the Ext.data.Model will be required before the proxy is created.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
16 Dec 2011 8:15 AM #3
A Test case is not easily chopped out of my app. Static analysis should show you all you need to know. You can't uses Ext.data.Model in the constructor unless is is defined
Which part of this don't you understand?
The && means it will be evaluated if you are going to successfully create your Proxy, and you can't use instanceof on an undefined type.Code:if (this.model !== undefined && !(this.model instanceof Ext.data.Model))
-
16 Dec 2011 8:39 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
But where will a proxy be used without a Store or a Model? It could actually be removed from the uses and have zero effect except save a little framework size.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
16 Dec 2011 9:02 AM #5
It can't be used without the Model which is why the requires is necessary. You pass the Model NAME (as a string) into the Proxy and you error on the isinstanceof 'Ext.data.Model' because Ext.data.Model does not exist because it wasn't required.
Part of this probably plays out because of this issue
http://www.sencha.com/forum/showthre....js-works.-Why
Which references another bug.
-
16 Dec 2011 9:03 AM #6
-
16 Dec 2011 9:10 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
Code:Ext.define('MyModel', { extend : 'Ext.data.Model', fields : [...], proxy : { type : 'ajax', .... } });There really is no reason to ever Ext.create('Ext.data.proxy.Ajax', {...})Code:Ext.define('MyStore', { extend : 'Ext.data.Store', model : 'SomeModel', proxy : { type : 'ajax', .... } });
And I said we *could* remove it and it would have no affect, not saying we are going to.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
16 Dec 2011 9:25 AM #8
Here is what I'm doing:
Code:Ext.define('IHawk.viewer.data.BatchProxy', { extend: 'Ext.data.proxy.Ajax', model: 'Batch', ...
-
16 Dec 2011 9:42 AM #9
What's the problem to move the dependency from uses to requires? This would make the code more readable even if it doesn't fix anything.
-
16 Dec 2011 10:17 AM #10
In my opinion the requires for a class needs to be correct. Currently it is only used for dynamic loading but who knows what other uses the requires property will have in future, for example in build utilities.
Given the current code I would say that Ext.data.Model needs to be in the requires for a proxy. The argument that proxies are only ever used with stores/models doesn't work for me.
One use case (off the top of my head) would be a singleton proxy instance that is shared between many stores. This may be defined before the store/model is loaded and currently I think that would fail.
I would actually suggest that a better solution to this is to remove the instanceof check and use isModel instead. Something like this maybe:
There's probably a good reason why the original code explicitly checked for undefined rather than truthyness, but you get the idea.Code:if (this.model && !this.model.isModel)) {
This removes the dependency on Ext.data.Model. However, there's still a dependency on Ext.ModelManager that I think should be explicitly included in the requires.
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote