# mehlm

> A straight forward state container

Latest version **0.0.2** (published 2018-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install mehlm
pnpm add mehlm
yarn add mehlm
bun add mehlm
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2018-02-11 |
| First published | 2018-02-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ragnar Rognstad |
| Maintainers | rognstadragnar |

## Links

- npm: https://www.npmjs.com/package/mehlm
- Repository: https://github.com/rognstadragnar/mehlm
- Homepage: https://github.com/rognstadragnar/mehlm#readme
- Issues: https://github.com/rognstadragnar/mehlm/issues
- npm.io page: https://npm.io/package/mehlm

## Recent versions

- 0.0.2 (latest) — 2018-02-11
- 0.0.1 — 2018-02-11

## README

<div align="center">
  <img src="https://raw.githubusercontent.com/rognstadragnar/mehlm/master/logo.jpg" alt="mehlm">
</div>

# mehlm

> 2kb JS view framework and state management

* Uses Picodom and Mehdux under the hood

## Usage

```Javascript
/** @jsx h */
import { h } from 'picodom';
import { render } from 'mehlm';

function view(state, actions, storeInstance) {
  return <h1>{state.value}</h1>;
}

const App = {
  state: {
    value: 0
  },
  actions: {
    inc: state => value => ({
      ...state,
      value: state.value + value,
    })
  },
  view,
  rootElm: document.querySelector('.app')
};

render(App);
```

#### The app object can have the following properties:

* **store**: An optional instance of a `mehdux` store. If present `state` and `actions` properties gets bypassed
* **state**: The initial state object (default is an empty object)
* **actions**: An object with the stores actions (default is an empty object)
* **view**: The `view`-function that gets passed state, actions and the store instance, returning the view (**required**)
* **rootElm**: The element in which `mehlm` gets rendered (**required**)
* **mapStateToProps**: A function that maps the state tree to props – you might not care about the entire state tree
* **mapActionsToProps**: A function that maps actions to props – you might not care about all the actions
* **preventUpdate**: To make nested connected components work, the store auto-emits updates to the state – this does not force a rerender, don't worry (default is `false`)

### Nested stateful connected components

Mehlm also support components being connect to the main store, with other `mapStateToProps` and `mapActionsToProps` functions.

```Javascript
/** @jsx h */
import { h } from 'picodom';
import { render, connect } from 'mehlm';


const AwesomeButton = ({ state, actions }) => {
  return <button onclick={actions.inc}>{state.value}</button>
}

const ConnectedButton = connect()(AwesomeButton);

// in `viewFn``
function view(state, actions, storeInstance) {
  return (
    <div>
      <ConnectedButton store={storeInstance}>
    </div>
  );
}

// ... render the app
```

---
_Source: https://npm.io/package/mehlm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
