# fluxing

> Simple implementation of Flux architecture.

Latest version **0.0.5** (published 2015-05-28) · ISC license · 0 weekly downloads

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

## Install

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

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2015-05-28 |
| First published | 2015-05-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 2 direct dependencies) |
| Install scripts | no |
| Author | mozisan |
| Maintainers | mozisan |

## Links

- npm: https://www.npmjs.com/package/fluxing
- Repository: https://github.com/mozisan/Fluxing
- Homepage: https://github.com/mozisan/Fluxing#readme
- Issues: https://github.com/mozisan/Fluxing/issues
- npm.io page: https://npm.io/package/fluxing

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^0.13.2
- [lodash](https://npm.io/package/lodash.md) ^3.8.0
- [eventemitter2](https://npm.io/package/eventemitter2.md) ^0.4.14

## Recent versions

- 0.0.5 (latest) — 2015-05-28
- 0.0.4 — 2015-05-09
- 0.0.3 — 2015-05-08
- 0.0.2 — 2015-05-08

## README

# Fluxing

Simple implementation of [Flux](https://facebook.github.io/flux/) architecture.

Fluxing provides ...

+ **Action**
+ **Store**
+ **Component**

Then, **Dispatcher** isn't provided, so you can build your application much simply.

*** _**ES6 syntax is preferred.**_ ***

## Action

### Example

```
import Fluxing from 'fluxing';

const EVENTS = {
  FOO: 'some unique string'
};

let FooAction = Fluxing.createAction({

  foo: function() {
    $.get('somewhere').done(response => {
      this.dispatch(EVENTS.FOO, response);
    });
  }

});
```

### Usage

Define the action object by `Fluxing.createAction`.

Then you can call `this.dispatch(eventName, ...args)` in each methods of the action object. (This invokes an event of `eventName` in background.)

## Store

### Example

```
import Fluxing from 'fluxing';

const EVENTS = {
  FOO: 'some unique string'
};

let FooStore = Fluxing.createStore({

  getInitialState() {
    return {
      baz: ['a', 'b']
    };
  },

  mapHandlers() {
    return {
      [EVENTS.FOO]: this.handleFoo
    };
  },

  handleFoo() {
    this.setState({baz: this.state.baz.concat('c')}, () => {
      console.log('handled foo');
    });
  }

});

```

### Usage

Define the store object by `Fluxing.createStore`.

Then you can call `this.setState(state [, callback])` in each methods of the store object.

And you can also define following methods...

+ **getInitialState**    
The store object has state, so define initial state of store object.
+ **mapHandlers**    
Map event handlers to correct event.

You **DO NOT** have to implement any method to set event listeners of each events because those will be set in background.

## Component

### Example

```
import React from 'react';
import Fluxing from 'fluxing';

import FooAction from 'path/to/action';
import BarStore from 'path/to/store';

let FooComponent = Fluxing.createClass({

  syncStores: [BarStore],

  displayName: 'Foo',

  componentDidMount() {
     FooAction.foo();
  },

  render() {
    return (
      <div>
        <h1>Title</h1>
        <p>{BarStore.state.bar}</p>
      </div>
    );
  }

});
```

### Usage

Define the component object by `Fluxing.createClass`.

As the method name is similar to `React.createClass`, you can define any attributes or methods of React, such as `displayName`, `getInitialState`, and so on.

Also, if you defined `syncStores` attributes with an array of `FluxingStore` instance, the component will be updated automatically as those `FluxingStore` instances update.

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