remood
v0.2.0
Published
Add remote-control features to your webapp
Downloads
4
Readme
remood.js
How it works
You start by creating an app.
var express = require('express'),
remood = require('remood'),
app = express(),
server = remood(app);
// Mount routes to your app
app.get('/', function(req, res) {
res.send('remood.js rocks!');
});
// BUT listen on the RETURNED server instance
server.listen(1337);
Then include frontend functionality
<script src="js/remood.js"></script>
Use it
Receiver
// Initialize remood
var r = new remood();
// Register remood events
r.on('yourEventId', function(msg) {
console.log(msg);
});
Remote
// Initialize remood as remote
var r = new remood({ remote: true });
r.send({
id: 'yourEventId',
type: eventName, // Most of the time 'click' or 'input'
data: 'my payload'
});
jQuery
Or use build in jQuery connector
<div id="play">Click me!</div>
$('#play').connect('click', function() {
// Callback after payload {
// id: 'play',
// type: 'click',
// data: ''
// } has been sent
console.log('#play has been clicked');
});
Development
In case you need to have the latest versions of dependencies:
$ cd node_modules/remood/
$ npm update --dev --depth 0
$ node ./node_modules/gulp/bin/gulp.js assets