dahlia-store
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

dahlia-store

State management for Dahlia

Installation

yarn add dahlia-store

Quick Start

import React from 'react'
 
import { createStore, observe } from 'dahlia-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'))

License

MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i dahlia-store

Weekly Downloads

15

Version

1.4.0

License

MIT

Unpacked Size

17.9 kB

Total Files

12

Last publish

Collaborators

  • forsigner