Giter VIP home page Giter VIP logo

remo.io's Introduction

NPM version build codecov

Remo.IO

An intuitive, robust and efficient RPC library for Node.js and the browser.

Purpose

This library allows to expose any functions on your Node.js server so that they can be called from the browser just as if they were normal, local JavaScript functions. Callback functions will be passed as reference, allowing the server in turn to call functions directly on the client.

Remo.IO aims to handle serialization of arbitrary objects (passed by value), take care of session and reconnection handling as well as properly propagate errors between server and client. It uses Socket.IO for transport.

Installation

npm install remo.io

Usage

Server

const remo = require('remo.io');

// define functions the server should expose to the client
const api = {
    hello: function (what) {
        console.log("Hello " + what + " from client!");
        return "Hello from server!";
    },
    // you can also expose builtins...
    log: console.log,
    // ... or even all functions of a module
    fs: require('fs'),
}
const remoServer = remo.createServer({ httpServer, api });

Client

// call a remote function on our server
remo.getServer().then((server) =>{
    
    server.api.hello("world").then((result) => {
        console.log("Function on server completed:", result);
    }).catch((err) => {
        console.error("Function on server failed:", err);
    });
        
})

For a full example, do the following:

git clone https://github.com/dapaulid/remo.io
cd remo.io
npm install
npm run example

Debugging

Remo.io uses debug to output traces, which allows to selectively enable debug output.

For the server, set the DEBUG environment variable before starting your app:

DEBUG=remo.io:* node myapp

In the browser, set the following variable using the developer console and reload your app:

localStorage.debug = "remo.io:*"

remo.io's People

Contributors

dapaulid avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.