Ad
  • Custom User Avatar
    SUPER:
    function baseClass(config){
      this.config = config;
      this.setConfig = function(value){};
    }
    
    MIXIN:
    function observableMixin(){
      this.listeners = {};
      this.addListener = function(name, callback){
        if(!this.listeners[name]) this.listeners[name] = [];
        this.listeners[name].push(callback);
      }
      this.removeListener = function(name, callback){
        this.listeners[name] = this.listeners[name].filter(
          function(fn){ 
            return fn != callback;
            });
      }
    }
    
    TypeError: c.hasListener is not a function
        at it
        at begin
        at it
        at describe
        at /runner/frameworks/javascript/cw-2.js:152:11
        at Promise._execute
        at Promise._resolveFromExecutor
        at new Promise
        at describe
        at /home/codewarrior/index.js:49:5
        at /home/codewarrior/index.js:96:5
        at Object.handleError
    

    There's no hasListener method anywhere, and no explanation of what the tests are trying to do - how am I even supposed to debug this?

    Edit: turns out there's a observableMixin.prototype.hasListener method, but again, if your solution is wrong and doesn't add this method to the created class, you will likely not be able to tell what's wrong.

  • Default User Avatar

    I'd recommend adding some example code in the description. Show how you expect the extend function to be invoked, with or without mixin and scope.

    Also, the function's argument names in the description doesn't match up with the argument names in the solution setup:

    extend('ChildClass', BaseClass, EventDispatcher, scope);
    function extend(className, superClass, mixin, scope)
    

    You should change one or both so that the argument names are consistent. The latter names are clearer IMHO.

    Then, change your bullet list so that it has a bullet item for each argument, describing the type (string, function, object), what it represents, and identifying the arguments which were optional.