0.3.10 • Published 5 years ago

allstore v0.3.10

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

AllStore

© 2018-present Harald Rudell harald.rudell@gmail.com (http://www.haraldrudell.com)

Single-truth store in 94% less code-lines

Demonstration Project: Demo-Context-Store Live source code

Allstore source code

Allstore npm package link

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.

© 2018-present Harald Rudell harald.rudell@gmail.com (http://www.haraldrudell.com)

0.3.10

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago