Search code examples
javascriptprototypemixins

Mixins with John Resig's Class Syntax


I've implemented simple Mixin behaviour that is compatible with John Resig's Class library. I'm asking for other JS folk to check the code and let me know if this is the way Mixin's normally work (I've not used them much before).

http://jsfiddle.net/aaronsnoswell/PHuvs/

If the code is incorrect, how should it work?


Solution

  • I think that necessary to take in consideration style of mixin implementation.

    For example if I make something like that:

    if(ninja instanceof CanRun){
        document.write("yea");
    }else{
        document.write("no");
    };
    

    Then should I get 'yes', or 'no'?

    In your implementation mixin is not class. I don't know is it your target but in many languages mixin is a fully valued class except that it not allows create instances.