Skip to content

bus.off() without parameters can be dangerous #5

@axelpale

Description

@axelpale

Today the following caveat happened to me:

bus.on('join', function () { do A });
...
var route;
(function tick() {
  bus.off(route);
  route = bus.on('quit', function () { do B and call tick });
  setTimeout(tick, 1000);
}());

There off call seems to take a parameter but because all off parameters are undefined, it acts like empty off call. This is a caveat of JavaScript in general but could there be a way to prevent this kind of thing happening for example by empasizing that route variables should be initialized with an empty string?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions