0.2.0 • Published 5 years ago

carlo-rpc-simple v0.2.0

Weekly downloads
9
License
-
Repository
github
Last release
5 years ago

carlo-rpc-simple

Simpler way of using Carlo's RPC API

Install

npm i carlo-rpc-simple

Usage

  • Node

    const carlo = require('carlo')
    const RPC = require('carlo-rpc-simple')
    
    class YourRPC extends RPC {
      yourNodeMethod () { ... } ────────────────────┐
    }                                               │
                                                    │
    const app = carlo.launch(...)                   │
    const yourRPC = new YourRPC()                   │
    await app.load(uri, yourRPC.loadParams())       │
    await yourRPC.remoteReady                       │
                                                    │
    yourRPC.remote.yourBrowserMethod() ───────────┐ │
  • Browser

    const RPC = require('carlo-rpc-simple')       │ │
                                                  │ │
    class YourRPC extends RPC {                   │ │
      yourBrowserMethod () { ... } ───────────────┘ │
    }                                               │
                                                    │
    const yourRPC = new YourRPC()                   │
    await yourRPC.loadParams()                      │
                                                    │
    yourRPC.remote.yourNodeMethod() ────────────────┘