real-share

2.0.2 • Public • Published

Welcome to real-share!

Directly call a function or method of a remote object from a Node.js App thru websocket that can be shared to any web frontend frameworks or mobile apps.

Installation

npm install real-share

or

yarn add real-share

CDN

<script src="https://unpkg.com/real-share/client.js"></script>

Server

// Server.js
const realShare = require('real-share/server')

class Person {
  constructor() {
    this.name = 'Trinmar Pogi'
  }
  run(speed, client) {
    console.log(client.id)
    return `${this.name} is running at ${speed}km/h`
  }
  eat(food) {
    return `${this.name} is eating ${food}`
  }
  async talk(speech) {
    await new Promise(r => setTimeout(r, 2000))
    return speech
  }
}

let human = new Person('Trinmar Pogi')

realShare(3000, {
  human
})

Client

async function init () {
  const realShare = require('real-share/client')
  // for CDN global variable named 'realShare'

  const { human } = await realShare('http://localhost:3131')
  console.log(await  human.run(100)) // Mr. Pogi is running at 100km/h
}
init()

Join and support our Community

Web and Mobile Developers PH

[ Facebook Page | Group ]

Join and support our Community
Web and Mobile Developers PH
[ Facebook Page | Group ]

Package Sidebar

Install

npm i real-share

Weekly Downloads

4

Version

2.0.2

License

ISC

Unpacked Size

302 kB

Total Files

10

Last publish

Collaborators

  • trinly01