Closed Bug 862601 Opened 12 years ago Closed 7 years ago

tabs module should have a getTabById() method

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: KWierso, Unassigned)

References

Details

(Whiteboard: [good next bug])

Attachments

(1 file)

When you have a tab's id value and you want to get that tab object, it'd be nice to not have to manually iterate through all open tabs, trying to match that id against each one. It'd be nice if there was some convenience function called getTabById(id) or something like that as part of the high-level tabs module to do it for us.
Assignee: nobody → jgriffiths
Whiteboard: [good first bug]
The PR currently is WIP, need to test on Fennec.
This ok with you Irakli?
Flags: needinfo?(rFobic)
not `getTabById` -> `getById`
or make the method an export from the tabs module separate from the tabs iterator.
(In reply to Erik Vold [:erikvold] [:ztatic] from comment #5) > or make the method an export from the tabs module separate from the tabs > iterator. hmm I guess this isn't possible.. the iterator is the export object..
The method name was Wes' original proposal, I have no strong opinion on getTabyId vs getById.
I'm fine with both `getTabyId` / `getById`. Although since it's exposed by tabs module tabs.getTabById feels like unnecessary repetition. This also got me thinking that it maybe better to just add: `tabs.get(handle) // => Tab` to continue the style established lately. For now we could just support string `id`'s, but in a future we can extend this to support `tabs.get(tabNode)`. Alternatively we could go with `tabs.from(handle)` to match closer ES.next Array.from
Flags: needinfo?(rFobic)
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] [@gozala] from comment #8) > I'm fine with both `getTabyId` / `getById`. Although since it's exposed by > tabs module tabs.getTabById feels like unnecessary repetition. > > This also got me thinking that it maybe better to just add: > > `tabs.get(handle) // => Tab` > > to continue the style established lately. For now we could just support > string `id`'s, but in a future we can extend this to support > `tabs.get(tabNode)`. +1 for `get`, good idea!
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] [@gozala] from comment #8) > Alternatively we could go with `tabs.from(handle)` to match closer ES.next > Array.from From my google searches it seems like Array.from converts array like things to a real array.
Assignee: jgriffiths → nobody
Can we leave this to a 3rd party module?
Flags: needinfo?(jgriffiths)
Someone could certainly write and publish a module that does this - I think it makes more sense for it to be in the tabs module but I also see that people aren't screaming for it.
Flags: needinfo?(jgriffiths)
Whiteboard: [good first bug] → [good next bug]
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: