#914 ✓ staged
Rick

Alias listen/unlistenwith on/off

Reported by Rick | February 12th, 2012 @ 11:46 AM | in 1.2 (closed)

I've noticed that on/off is quickly becoming a "de-facto" standard for event-related APIs. jQuery shifted to this as it's primary event API, Node.js has established it as the only event API, it has been discussed as a hypothetical alternative to addEventListener/removeEventListener and it even appears in Dart. The cost is minimal:


Popcorn.p.on = Popcorn.p.listen;
Popcorn.p.off = Popcorn.p.unlisten;

// Bonus!
Popcorn.p.emit - Popcorn.p.trigger;

I think it makes our code look even nicer:



var $pop = Popcorn("#video");

$pop.on("canplay", function() {

  console.log("Ready!");

});

I have a patch/tests ready go, pending discussion.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Popcorn.js is an HTML5 video framework that lets you bring elements of the web into your videos.

Popcorn.js is a project of Web Made Movies, Mozilla's Open Video Lab.

Shared Ticket Bins

Pages