# mobx-create-store

> Mobx minimal API

Latest version **1.0.0** (published 2018-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install mobx-create-store
pnpm add mobx-create-store
yarn add mobx-create-store
bun add mobx-create-store
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-06-07 |
| First published | 2018-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Robert Gonzales |
| Maintainers | robertgonzales |

## Links

- npm: https://www.npmjs.com/package/mobx-create-store
- npm.io page: https://npm.io/package/mobx-create-store

## Dependencies (1)

- [mobx](https://npm.io/package/mobx.md) ^4.3.0

## Recent versions

- 1.0.0 (latest) — 2018-06-07

## README

# mobx-create-store

This library is just a util on top of [mobx](https://github.com/mobxjs/mobx).

### Installation

```
$ npm install --save mobx mobx-react mobx-create-store
```

### Usage

```js
import React from "react"
import moment from "moment"
import { observer } from "mobx-react"
import { createStore } from "mobx-create-store"

const timer = createStore({
  ticks: 0,
  id: null,
  toggle() {
    if (!this.id) {
      this.id = setInterval(() => this.ticks++, 10)
    } else {
      this.id = clearInterval(this.id)
    }
  },
  get time() {
    return moment(this.ticks * 10).format("mm:ss")
  },
  get fraction() {
    return moment(this.ticks * 10).format("SS")
  },
  get label() {
    return this.id ? "Stop" : "Start"
  },
})

export default observer(() => (
  <div>
    <p>{timer.time}<small>{timer.fraction}</small></p>
    <button onClick={timer.toggle}>{timer.label}</button>
  </div>
))
```

### How it works

Under the hood `createStore` does the following:

- Turns key/value pairs into observables.
- Turns getters into computed properties.
- Decorates methods with action.bound.

All normal mobx gotchas apply.

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