0.0.1-b2 • Published 3 years ago

slurppy v0.0.1-b2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

slurppy

Simple reactive array db for react.

Usage

import { useDispatcher, useSlurp, SlurpProvider } from 'slurppy'

const App = () => {
  const { state, updated } = useSlurp()
  const { insert, reset } = useDispatcher()

  const addItem = () => {
    insert({ new: 'another' })
  }

  return (
    <SlurpProvider initialData={[{ hello: 123 }]} autoRead autoWrite>
      <div>
        {JSON.stringify(state)}

        {JSON.stringify(window.localStorage.getItem('slurpdb'))}

        <button onClick={addItem}>add new item</button>
        <button onClick={reset}>remove all</button>
      </div>
    </SlurpProvider>
  )
}

export default App

© 2021 | License

0.0.1-b2

3 years ago

0.0.1-b1

3 years ago

0.0.1

3 years ago