1.1.2 • Published 3 years ago

livestate v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

livestate

livestate.io client

NPM JavaScript Style Guide

Install

npm install --save livestate

Usage

import { useLiveState, LiveStateProvider } from 'livestate'

const App = () => (
  <LiveStateProvider uri='wss://try.livestate.io/socket'>
    <CounterExample />
  </LiveStateProvider>
)

const counterId = 'the-universal-global-counter-id'
const CounterExample = () => {
  const [state, setState] = useLiveState({
    id: counterId,
    defaultValue: { counter: 0 }
  })

  return (
    <div>
      <button onClick={() => setState({ counter: state.counter + 1 })}>
        Increment
      </button>
      <p>Counter: {state.counter}</p>
    </div>
  )
}

License

MIT © webdeb

1.1.1

3 years ago

1.1.0

3 years ago

1.1.2

3 years ago

1.0.3

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago