javascript - How are Tab IDs generate in Chrome? -


are created incrementally? integers, i'm wondering if generated in particular way. knowing useful me application writing.

edit: need keep in memory ids , thinking if can order them able search. if created increasing number easy implement search binary search, that's why asking

the thing can find in documentation pertaining id following excerpt:

id ( integer ) id of tab. tab ids unique within browser session.

so can glean no 2 tabs ever same id in same session. there's no information in docs how they're generated.

ultimately think approach predictive in sense doomed bugs & failure, should building responsive application vs. predictive one.

instead of assuming next tab opened id # 12, capture creation of tab, you'll know id , can perform operations based on that.

what need tab oncreated event. when tab created you'll tab object can tabid , windowid , perform whatever actions desire.

since didn't tell ultimate goal, can't give specific examples / code out other pointing in right direction.


continuation comments:

if you're looking tab id wouldn't easier store tab meta-data in dictionary instead of list?

var metadatarepository = {}; metadatarepository[tab.id] = tab.metadata; 

then:

var metadata = metadatarepository[tabid]; if (metadata) {    // stuff } 

even more information:

as of current chrome (19.xxx...) v8 engine supports javascript 1.6 method of array.filter(...)

i did little test here simulates searching array using filter , doing type inspection & string search each iteration (something common).

it took 25ms on machine (relatively new, i7-2600k) blast through 10,000 entries. while isn't fast compared compiled languages, it's going sub millisecond when dealing 100ish tabs. dont think need worry performance much.

if app looking up, consider local cache or dictionary mentioned above.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -