# pedrofurtado-redux

> My own Redux. Just for fun.

Latest version **1.0.2** (published 2018-08-15) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install pedrofurtado-redux
pnpm add pedrofurtado-redux
yarn add pedrofurtado-redux
bun add pedrofurtado-redux
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-08-15 |
| First published | 2018-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pedro Furtado |
| Maintainers | pedrofurtado |
| Keywords | redux, redux-clone, javascript, ecmascript |

## Links

- npm: https://www.npmjs.com/package/pedrofurtado-redux
- Repository: https://github.com/pedrofurtado/pedrofurtado-redux
- Issues: https://github.com/pedrofurtado/pedrofurtado-redux/issues
- npm.io page: https://npm.io/package/pedrofurtado-redux

## Recent versions

- 1.0.2 (latest) — 2018-08-15
- 1.0.1 — 2018-08-15
- 1.0.0 — 2018-08-15
- 0.0.1 — 2018-08-14

## README

# Pedro Furtado Redux

My own Redux. Just for fun.

## Example usage

```javascript
import { createStore } from 'pedrofurtado-redux';

const reducer1 = (state = [], action) => {
  switch(action.type) {
    case 'SOME_ACTION':
      return [...state, action.payload];
    case 'ANOTHER_ACTION':
      return [...state, action.another_payload];
    case 'LAST_ACTION':
      return [];
    default:
      return state;
  }
};

const reducer2 = (state = 5, action) => {
  switch(action.type) {
    case 'UNIQUE_ACTION':
      return 9;
    default:
      return state;
  }
};

const middleware1 = (state, action) => {
  console.log('Middleware 1 executing!');
  console.log('State at this moment', state);
  console.log('Action at this moment', action);
  console.log('Middleware 1 executed!');
}

const middleware2 = (state, action) => {
  console.log('Middleware 2 executing!');
  console.log('State at this moment', state);
  console.log('Action at this moment', action);
  console.log('Middleware 2 executed!');
}

const store = createStore(
  {
    key1: reducer1,
    key2: reducer2
  },
  [
    middleware1,
    middleware2
  ]
);

store.subscribe(() => {
  console.log('Changes detected in state!');
});

store.dispatch({ type: 'SOME_ACTION', payload: 'SOMETHING' });
store.dispatch({ type: 'ANOTHER_ACTION', another_payload: 'ANOTHER_THING' });
store.dispatch({ type: 'ACTION_THAT_NOT_EXISTS' });
store.dispatch({ type: 'UNIQUE_ACTION' });
```

## Build

To build the `dist/` folder, execute the following command:

```bash
$ docker-compose up --build -d
```

# Alert: Don't use it in your projects!

This repo is just for study, in order to understand how Redux works behind the scenes.
Naturally, the official Redux is much more flexible and complex.
But, for fun, I've made a simple version of it.

Enjoy!

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