Box2D's collision event listeners only work (more or less) globally: you create a listener and attach it to the world, which will get called every time there's a collision.
To make things a little more managable, here's a module which can take a
box2dweb-commonjs world and give you
EventEmitter in return. You can also listen to individual fixtures
for ease of use.
npm install box2d-events
EventEmitter which will emit the following events:
begin(fixtureA, fixtureB, info)when a collision first occurs between two objects.
end(fixtureA, fixtureB, info)when a collision stops occurring between two objects.
EventEmitter which will emit the same events as above, except only
when they involve that specific object. Note that the first fixture will
always be the one not belonging to the listener.