Closed Bug 636142 Opened 13 years ago Closed 13 years ago

EventEmitter.once

Categories

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

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: irakli, Assigned: irakli)

Details

Attachments

(2 files)

In many cases we set an event listener that is removes itself on a first call. I think it will be extremely useful to implement following API:

eventEmitter.once('EventType', listener).

Also similar thing have recently been added to [nodejs](http://nodejs.org/docs/v0.4.1/api/events.html#emitter.once). As a matter of fact all other major frameworks also provide APIs to do similar thing.

In addition I would also propose to implement following low lever module 'api-utils/dom/events' (as this seems to be very useful with regular dom events):

require('dom/events').on(element, 'load', onLoad, [capture=false])
require('dom/events').removeListener(element, 'load', onLoad, [capture=false])
require('dom/events').once(element, 'load', onLoadOnly, [capture=false])
Attachment #515173 - Flags: review?(myk)
Comment on attachment 515173 [details]
Pointer to pull request

Just a few minor issues, as noted in the pull request.
Attachment #515173 - Flags: review?(myk) → review-
Attachment #519107 - Flags: review?(myk)
Assignee: nobody → rFobic
Attachment #519107 - Flags: review?(myk) → review+
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: