@alexmerced/simplerpc-client
TypeScript icon, indicating that this package has built-in type declarations

1.1.41 • Public • Published

SimpleRPC - Client

npm install @alexmerced/simplerpc-client

The SimpleRPC framework is a framework for creating very simple lightweight RPC APIs for use with any backend or frontend framework with a redux/useReducer like API.

Actions take the signature of

(payload: Object, context: Object) => response:Any

The client function then can be called like so:

rpcDispatch({type: "actionName", payload: {arg1: 1, arg 2: "hello"}})

Setting up the Client

import {createClient} from "simplerpc-client"

const rpcDispatch = createClient({
    url: "http://localhost:4000/rpc",
    headers: {
        "authorization": "..."
    }
})

export default rpcDispatch

Then assuming your server is setup with @alexmerced/simplerpc-server at the specific endpoint you can make rpc calls like so.

await rpcDispatch({type: "createTodo", payload: {
    message: "Lunch"
}})

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @alexmerced/simplerpc-client

      Weekly Downloads

      1

      Version

      1.1.41

      License

      ISC

      Unpacked Size

      3.55 kB

      Total Files

      5

      Last publish

      Collaborators

      • alexmerced