PDA

View Full Version : Return true instead of nothing



Stuart
18 Nov 2010, 7:57 AM
I have very basic knowledge of JavaScript so please forgive me if this sounds a tad daft.
Wouldn't it be better to return true for methods that returning nothing.
This would allow me to write code such as this:


if(grid.getStore().load()){
//Some code here
}

I know that I can use a listener for this and other methods (bad example) but sometimes it would be convenient to do it this way to make sure that code executes in the correct sequence. I don't think that this would do any harm?

tryanDLS
18 Nov 2010, 8:33 AM
load() is async, so returning true there doesn't mean anything. You have to wait til the request completes to see what result is.

http://www.sencha.com/learn/Ext_FAQ

danguba
18 Nov 2010, 9:05 AM
Yeah so U should basically add listener on grid store and listen 4 load event and then do Ur stuff

Stuart
18 Nov 2010, 12:37 PM
Thanks for the quick response, I'll check out that Ext_FAQ first thing.