1.0.1 • Published 5 years ago

@fishx/store v1.0.1

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

@fishx/store

State management for fishx

Installation

yarn add @fishx/store

Quick Start

import React from 'react'

import { createStore, observe } from '@fishx/store'

const store = createStore({
  count: 1,
  increment() {
    store.count++
  },
  decrement() {
    store.count--
  },
  async asyncIncrement() {
    await new Promise(resolve => setTimeout(resolve, 1000))
    store.count++
  },
})

const App = observe(() => (
  <div>
    <span>{store.count}</span>
    <button onClick={store.decrement}>-</button>
    <button onClick={store.increment}>+</button>
    <button onClick={store.asyncIncrement}>async+</button>
  </div>
))

ReactDOM.render(<App />, document.getElementById('root'))