0.5.0 • Published 5 years ago

carlo-rpc-store v0.5.0

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

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 sync both ways or just update the browser|node
    • rpc Options for carlo-rpc-simple
    • undb Options for undb
0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago