src/index.js
function listenAndPromise(callback, bindContext) {
        var me = this;
        bindContext = bindContext || this;
        this.willCallPromise = (this.willCallPromise || 0) + 1;

        var removeListen = this.listen(function() {

            if (!callback) {
                throw new Error("Expected a function returning a promise but got " + callback);
            }

            var args = arguments,
                returnedPromise = callback.apply(bindContext, args);
            return me.promise.call(me, returnedPromise);
        }, bindContext);

        return function () {
          me.willCallPromise--;
          removeListen.call(me);
        };

    }
function listenAndPromise(callback, bindContext) {
        var me = this;
        bindContext = bindContext || this;
        this.willCallPromise = (this.willCallPromise || 0) + 1;

        var removeListen = this.listen(function() {

            if (!callback) {
                throw new Error("Expected a function returning a promise but got " + callback);
            }

            var args = arguments,
                returnedPromise = callback.apply(bindContext, args);
            return me.promise.call(me, returnedPromise);
        }, bindContext);

        return function () {
          me.willCallPromise--;
          removeListen.call(me);
        };

    }
function listenAndPromise ( callback , bindContext ) { var me = this ; bindContext = bindContext || this ; this . willCallPromise = ( this . willCallPromise || 0 ) + 1 ; var removeListen = this . listen ( function ( ) { if ( ! callback ) { throw new Error ( "Expected a function returning a promise but got " + callback ) ; } var args = arguments , returnedPromise = callback . apply ( bindContext , args ) ; return me . promise . call ( me , returnedPromise ) ; } , bindContext ) ; return function ( ) { me . willCallPromise -- ; removeListen . call ( me ) ; } ; }
Subscribes the given callback for action triggered, which should
return a promise that in turn is passed to `this.promise`

@param {Function} callback The callback to register as event handler
Subscribes the given callback for action triggered which should return a promise that in turn is passed to this . promise