0.1.1 • Published 13 years ago
prescription-net
Licence
—
Version
0.1.1
Deps
4
Vulns
0
Weekly
0
Prescription Net
This exposes the core node.js net module as a set of functions that
return Prescription FRP Observables instead of taking callbacks.
Example
Echo server:
var net = require("prescription-net");
// Create a server instance
var server = new net.Server();
// Make the server listen on port 3000, we're only interested in the connection
// Observable, so we subscribe() that one through and we subscribe to each of
// the sockets it's emit back to themselves (echo server)
server.listen(3000).connection.subscribe(function(observables) {
observables.socket.subscribe(observables.socket);
});
TCP client:
var net = require("prescription-net");
var client = new net.Socket();
var observables = client.connect(3000);
var connect = observables.connect;
var socket = observables.socket;
socket.map(function(data) {
return data.toString();
}).subscribe(function(data) {
console.log(data);
});
connect.subscribe(function() {
socket.onNext("beep bop boop");
});