cujojs/meld

when object instace is advised?

Closed this issue · 1 comments

if(this instanceof advised) {
                // shamelessly derived from https://github.com/cujojs/wire/blob/c7c55fe50238ecb4afbb35f902058ab6b32beb8f/lib/component.js#L25
                context = objectCreate(orig.prototype);
                callOrig = function (args) {
                    return applyConstructor(orig, context, args);
                };

            } 

for the above code , I do not understand , when this instance will be advised

I test by the follow code

var user=new User();
meld.before(User.prototype, 'fun1', function() {
    console.log('hello fun1');
    });
    meld.before(user, 'fun1', function() {
      console.log('hello new fun1');
    });

but did not capture user or User.prototype as advised instance

got it

Advised = meld.before(Advised, verifyContext);
new Advised();