# flux-up

> Manage modules and services for flux based applications

Latest version **0.1.3** (published 2015-04-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install flux-up
pnpm add flux-up
yarn add flux-up
bun add flux-up
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2015-04-29 |
| First published | 2015-04-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Davide Fiorello |
| Maintainers | davidefiorello |
| Keywords | react, flux, fluxxor |

## Links

- npm: https://www.npmjs.com/package/flux-up
- Repository: https://github.com/sytac/flux-up
- Issues: https://github.com/sytac/flux-up/issues
- npm.io page: https://npm.io/package/flux-up

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2015-04-29
- 0.1.2 — 2015-04-29

## README

# Flux Up
*Keep clean your code building huge flux/react apps.*

## Why?
- Building TodoMVC app is fancy but useless in daily work. 
- Huge apps need to be modularized.
- Huge apps need services.
- Flex does not provide patterns to modularize apps and to manage services.

## Installation

Install using npm

```bash
$ npm install --save flux-up
```

## Quick start

#### Prepare your folder struct
```
flux-up-project
│  README.md
│  ...    
|
└──src
   │  app.js
   │  app.module.js
   |  translation.service.js
   │
   ├──modules
   │  ├--foo
   |  |   foo.js 
   │  │   foo.module.js
   |  |   foo.stores.js
   |  |   foo.actions.js
   |  |   foo.services.js
   │  │   ...
   |  ├--bar
   |  |   bar.js 
   │  │   bar.module.js
   |  |   bar.stores.js
   |  |   bar.actions.js
   |  |   bar.services.js
   │  │   ...
...
```

#### Add a module description file
Each module require a *.module.js file containing the description of the module. No fields are required. Add an "actions" field for actions, a "stores" fields for stores. This fields are passed directly to the addStores and addActions callbacks set in the ```init``` method. Check your flux library docs for the right format. Examples are provided using [Fluxxor](http://fluxxor.com/).  

```javascript
/* foo.module.js */
var FooStore = require('./foo.store');
var fooActions = require('./foo.actions'); 
var fooService = require('./foo.service');

module.exports = {
  actions : {
    'foo' : fooActions
  },
  stores : {
    // Fluxxor require store instance, other library could work differently
    // Check the flux lib documentation  
    'foo' : new FooStore()
  },
  services : {
    'fooService' : fooService
  }
};

```

#### Init the app

```javascript
/* app.js */
var fluxUp = require('flux-up');

// Init your flux library
var flux = new Fluxxor.Flux();

// Init app with callback for adding stores and actions
fluxUp.init(
    flux.addStores.bind(flux), 
    flux.addActions.bind(flux)
);

// Register modules 
fluxUp.modules.register('app', require('./app.module'));
fluxUp.modules.register('foo', require('modules/foo/foo.module'));
fluxUp.modules.register('bar', require('modules/bar/bar.module'));

// register additional services
fluxUp.services.register('translationService', require('./translation.service'));

```
In the register operation, stores and actions are directly added to flux instance.
You can access it using the methots provided by the flux library:

```
/* Eg. */
this.getFlux().store('foo');

this.getFlux().actions.foo.someAction();
```
 
 The services are added directly to the flux-up module and could be retrieved everywere:
 
 ```
 var fluxUp = require('flux-up');
 ...
 var translationService =  fluxUp.services.get('translationService');
 
 ```

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