@fishx/store
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@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'))

Readme

Keywords

none

Package Sidebar

Install

npm i @fishx/store

Weekly Downloads

0

Version

1.0.1

License

none

Unpacked Size

16.2 kB

Total Files

11

Last publish

Collaborators

  • whalecloud-developer