Here `this.emitWhenListener` is used, but in onNotification, `appMessages.emitWhenListener` is used. Either is fine, but one style should be used. Use of `appMessages` prevents the need for a .bind(this) when passing these functions to `mozSetMessageHandler`. Which, btw, looks like there is a bug here since the `mozSetMessageHandler` for `onActivityRequest` just passes the function ref, so the `this` reference here will fail.

Since this code structures appMessages as a declared object with properties, I would favor using `this`, but that means using bind(this) below for the  `mozSetMessageHandler` calls.