0.0.1 • Published 11 years ago

livesync v0.0.1

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

livesync

Automatically reloads the page as soon as a change is detected.

Usage

Quite simple, actually, here's how to use it in express.js

In Node

var express = require("express"),
    app = express(),
    livesync = require("livesync"),
    live = new livesync();

app.use(express.static(__dirname + "/static"));
live.watch(__dirname + "/static");

app.listen(8080);

In HTML, you just add socket.io and livesync.

<script src="http://127.0.0.1:46281/socket.io/socket.io.js"></script>
<script src="http://127.0.0.1:46281/socket.io/livesync.js"></script>

Alternatively, to keep it all in one port,

In Node

var express = require("express"),
    app = express(),
    server = require("http").createServer(app),
    io = require("socket.io").listen(server),
    livesync = require("livesync"),
    live = new livesync(io);

app.use(express.static(__dirname + "/static"));
app.use(live.middleware());

server.listen(8080);

In HTML, you just add socket.io and livesync.

<script src="/socket.io/socket.io.js"></script>
<script src="/socket.io/livesync.js"></script>
0.0.1

11 years ago