rofrischmann/alveron

View on GitHub
docs/api/createStore.md

Summary

Maintainability
Test Coverage
# createStore

It creates a new store instance that provides both [Provider](Provider.md) and [Consumer](Consumer.md) components as well as a shorthand [Wrapper](Wrapper.md) component to interact with the store.

It accepts a single options object, that allows the following options.

## Options
| Argument | Type | Description |
| -------- | ---- | ----------- |
| actions | *(Object?)* | A map of [actions](../concepts/Actions.md) where the *key* represents the action name and the *value* represents the action reducer |
| effects | *(Object?)* | A map of [effects](../concepts/Effects.md) where the *key* represents the effect name and the *value* represents the updater |
| model | *(any?)* | The default [model](../concepts/Model.md) reflecting the initial state shape |

## Returns
*(Object)* an object containing the [Provider](Provider.md), [Consumer](Consumer.md) and [Wrapper](Wrapper.md) components. 

## Example
```javascript
import { createStore } from 'alveron'

const model = 0
const actions = {
  increment: state => state + 1,
  decrement: state => state - 1
}

const { Provider, Consumer, Wrapper } = createStore({
  actions,
  model
})
```