0.3.0 • Published 8 years ago

consus-flux v0.3.0

Weekly downloads
8
License
Unlicense
Repository
github
Last release
8 years ago

consus-flux

Build Status codecov npm devDependency Status

Flux modules for the Consus project

Installing

npm install consus-flux --save

Using the Dispatcher

import { Dispatcher } from 'consus-flux';

Dispatcher.handleAction('INCREMENT', {
    amount: 5
});

Using the Store

import { Store } from 'consus-flux';

let count = 0;

class CounterStore extends Store {

    getCount() {
        return count;
    }

}

const store = new CounterStore();

store.registerHandler('INCREMENT', data => {
    count += data.amount;
    store.emitChange();
});

store.registerHandler('DECREMENT', data => {
    count -= data.amount;
    store.emitChange();
});

export default store;

Listening to a Store

import CounterStore from './counter-store';

function handleChange() {
    console.log('The count is now: ' + CounterStore.getCount());
}

CounterStore.addChangeListener(handleChange);

setTimeout(() {
    CounterStore.removeChangeListener(handleChange);
}, 10000);

Developing

Getting Started

# Clone the repository
git clone git@github.com:TheFourFifths/consus-flux.git
# Enter the project directory
cd consus-flux
# Install dependencies
npm install
# Build the project
npm run build
# Run the test suite
npm test

Development Scripts

  • npm test: Run the test suite
  • npm run lint: Run the linter
  • npm run build: Build the usable .dist directory
  • npm run coverage: Generate a code coverage report

Project File Structure

  • src: The project's source code
  • test: The project's tests
    • lib: Miscellaneous library modules
    • unit: Unit tests
0.3.0

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago