0.5.0 • Published 5 years ago
carlo-rpc-store v0.5.0
carlo-rpc-store
A simple two-way store for Carlo that syncs changes between Node and Browser.
Uses carlo-rpc-simple & undb.
Install
npm i carlo-rpc-store
Usage
Node
const carlo = require('carlo') const carloStore = require('carlo-rpc-store') const app = carlo.launch(...) const [store, onChange, loadParams, remoteReady] = carloStore() await app.load(uri, loadParams) await remoteReady onChange(() => { /* Fires whenever store changes, locally or on remote */ }) store.node = 'value'
Browser
const carloStore = require('carlo-rpc-store') const [store, onChange] = carloStore() onChange(() => { /* Fires whenever store changes, locally or on remote */ }) store.browser = 'value'
API
const [store, onChange, loadParams, remoteReady] = carloStore(opts)
opts
remote
(both|browser)[=both]
Whether to syncboth
ways or just update thebrowser|node
rpc
Options for carlo-rpc-simpleundb
Options for undb