1.1.41 • Published 1 year ago

@alexmerced/simplerpc-client v1.1.41

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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"
}})
1.1.1

1 year ago

1.1.41

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago