jQuery-Like Selector

Get the latest news on new features, bug fixes and version updates right here!

jQuery-Like Selector

Postby rob » Fri Dec 20, 2013 11:58 pm

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.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: jQuery-Like Selector

Postby luke » Tue Jan 07, 2014 12:22 am

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]];

luke
 
Posts: 6
Joined: Wed Dec 18, 2013 4:52 pm

Re: jQuery-Like Selector

Postby rob » Sun Mar 23, 2014 7:38 pm

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! :)
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm


Return to New Features, Latest Versions & General Updates

Who is online

Users browsing this forum: No registered users and 1 guest
cron