# mobx-noclass

> Create a mobx store without the use of es6 classes.

Latest version **1.0.1** (published 2016-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install mobx-noclass
pnpm add mobx-noclass
yarn add mobx-noclass
bun add mobx-noclass
```

## 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.1 |
| Published | 2016-07-10 |
| First published | 2016-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Ny Fanilo Andrianjafy |
| Maintainers | ny.fanilo |
| Keywords | mobx, es6, helper |

## Links

- npm: https://www.npmjs.com/package/mobx-noclass
- Repository: https://github.com/nylo-andry/mobx-noclass
- Homepage: https://github.com/nylo-andry/mobx-noclass#readme
- Issues: https://github.com/nylo-andry/mobx-noclass/issues
- npm.io page: https://npm.io/package/mobx-noclass

## Dependencies (1)

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

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-07-10
- 1.0.0 — 2016-07-10

## README

# mobx-noclass

Utility function to create a mobx store without the use of es6 classes.

## Why?

I tend to stay away from ES6 classes. They do are convenient, but I have some issues with them:

* They favor classical inheritance over prototypal inheritance.
* They favor inheritance over composition.
* They re-introduce the `new` keyword which comes from languages that works with classical inheritance and I feel that it strays away from JavaScript's true nature to make developers coming from Java, C++ and other similar languages more comfortable.
* Creating private fields is either hacky or not elegant.

For more information, consult this [awesome list](https://github.com/joshburgess/not-awesome-es6-classes).

## Usage

### createMobxStore(observables, actions)

Creates a new mobx store by passing the observables and the actions on the observables as objects.

Having the actions defined in objects will allow you to have closures that will serve as private fields.

### Example

    import { createMobxStore } from 'mobx-noclass';

    let store = createMobxStore({
      value: 0,
      next() {
        return this.value + 1;
      },
      previous() {
        return this.value - 1;
      }
    },
    {
      inc() {
        return this.value++;
      },
      dec() {
        return this.value--;
      }
    });

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