Skip to content

garris/sleepyhollow-phantom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sleepyhollow-phantom

PhantomJS binder for two-way communication with Node.js. An IPC library in two modules, used in conjunction with sleepyhollow-node, via stdin and stderr. No socket.io or server-page hacks required.

usage

To receive messages from Node.js, require and invoke sleepyhollow. This returns an EventEmitter instance which allows you to implement your own message passing system.

// this is PhantomJS code, not Node.js!

var sleepyhollow = require('./node_modules/sleepyhollow-phantom/index.js');
var mrhyde = sleepyhollow();

mrhyde.on('render', function(url) {
    var page = require('webpage').create();
    page.open(url, function(status) {
        page.render(url + ".png");
        mrhyde.emit("rendered");
        page.close();
    });
});

mrhyde.on('end', function() {
    phantom.exit();
});

See the usage example for the corresponding Node.js code.

About

PhantomJS binder for two-way communication with Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%