Page 1 of 1

jQuery-Like Selector

PostPosted: Fri Dec 20, 2013 11:58 pm
by rob
Hi all,

The ige.$$ and ige.$$$ methods now return a jquery-like array with super-powers so you can now call a method on all returned items from a category or group selector e.g.:

Code: Select all
new IgeEntity().addGroup('button').mount(ige.$('baseScene'));
new IgeEntity().addGroup('button').mount(ige.$('baseScene'));
new IgeEntity().addGroup('button').mount(ige.$('baseScene'));


Then to hide all those entities with the group "button":

Code: Select all
ige.$$$('button').hide();


The $$$ method still returns an array that you can iterate over if you so choose. All methods that exist in the IgeEntity class also exist in the new IgeArray (which is what the $$ and $$$ methods now return). Dev branch only as usual.

Re: jQuery-Like Selector

PostPosted: Tue Jan 07, 2014 12:22 am
by luke
Hi Rob, quick question about this feature.

Do you know if there is a performance disadvantage to extending the base Javascript array? I know V8's underlying C++ uses arrays very differently based on how you use it in Javascript. I don't know if extending array functionality causes any problems or not. One thing we immediately noticed is that Array.concat() no longer works as expected. Calling .concat on an IgeArray returns a Javascript array with each IgeArray as an element.

Code: Select all
// Javascript Array
var test1 = [1, 2];
var test2 = [3, 4];

test1.concat(test2);
// Result = [1, 2, 3, 4];

// IgeArray
var test1 = new IgeArray();
test1[0] = 1;
test1[1] = 2;

var test2 = new IgeArray();
test2 = 3;
test2 = 4;

test1.concat(test2);
// Result = [IgeArray[2], IgeArray[2]];


Re: jQuery-Like Selector

PostPosted: Sun Mar 23, 2014 7:38 pm
by rob
luke wrote:Hi Rob, quick question about this feature.

Do you know if there is a performance disadvantage to extending the base Javascript array? I know V8's underlying C++ uses arrays very differently based on how you use it in Javascript. I don't know if extending array functionality causes any problems or not. One thing we immediately noticed is that Array.concat() no longer works as expected. Calling .concat on an IgeArray returns a Javascript array with each IgeArray as an element.

Code: Select all
// Javascript Array
var test1 = [1, 2];
var test2 = [3, 4];

test1.concat(test2);
// Result = [1, 2, 3, 4];

// IgeArray
var test1 = new IgeArray();
test1[0] = 1;
test1[1] = 2;

var test2 = new IgeArray();
test2 = 3;
test2 = 4;

test1.concat(test2);
// Result = [IgeArray[2], IgeArray[2]];


Hmm, that makes sense but not necessarily wanted. I don't think there are any performance hits from this since it's using the array prototype as it's base... it's like extending anything else including objects etc.

If it's causing issues for anyone I'll pull it out of the engine though! :)