can't pass "this" as parameter in spookyjs emit

195 Views Asked by At

I'm trying to pass "this" as an argument to Spooky.emit, but I get no output. This is my code:

var Spooky = require('spooky');

var spooky = new Spooky({
    child: {
        transport: 'http'
    },
    casper: {
        logLevel: 'debug',
        verbose: true
    }
}, function() {

    spooky.start(
        'http://google.com');
    spooky.then(function() {
        this.emit('msg', this);
    });
    spooky.run();
});

spooky.on('msg', function(msg) {
    console.log(msg);
});

Someone knows what could be wrong here?

0

There are 0 best solutions below