allstore
v0.3.10
Published
A React Single-Truth store in 94% less code-lines by Harald Rudell
Downloads
36
Maintainers
Readme
AllStore
© 2018-present Harald Rudell [email protected] (http://www.haraldrudell.com)
Single-truth store in 94% less code-lines
Demonstration Project: Demo-Context-Store Live source code
Features
- Single-truth store as plain object
- useAllstore React 16.7 hook or traditional connect high-order component
- Defaults to pure components, support for traditional components
Design
- Store manipulation via ECMAScript module imports
- No name-collision via import aliasing and configurable store-slice names
- Use of React 16.3 context and internal subscription mechanic
Published using Lib Create React App that allows React components to be publicly published as npm packages
click for Video presentation, 10 min
Usage
- yarn add allstore
API Reference
import { store, Store, useAllstore, connect, notify, getState, subscribe, storeContext, StoreProvider, StoreConsumer } from 'allstore'
- Store: component that makes the store context available, see Usage
- const {storeProps…} = useAllstore(mapStateToProps, {props…}, [pure: false]): React 16.7 hook, see Usage props to Component
- connect(mapStateToProps, options)(Component): provides store properties as
- mapStateToProps(Object state, Object props) Object: defines what props the wrapped component needs based on the store state and its other props
- options: {displayName: string, pure: boolean: default true}
- store: plain store object
- notify() all components evaluate the new store state for redraw
- subscribe() subscription for store changes, typically only used by connect or useAllstore
- getState() gets the store plain object to allow for modifications
- storeContext for a class that wants to access the store context, used by connect
- StoreProvider StoreConsumer for custom rendering of the React 16.3 context
link: Hire Harald Rudell
link: Sponsor Harald Rudell
Lib Create React App creates shareable libraries from projects bootstrapped with Create React App.