1.1.1 • Published 8 years ago

no-react-reflux v1.1.1

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

#Simple lightweight implementation of the Reflux

Uses just NodeJS EventEmitter.

##To create an action

import {Action} from 'no-react-reflux';

export default new Action([
    'actionName',
    'anotherActionName',
    ['complicatedAction', complicatedAction]
]);

function complicatedAction() {
    // Do real stuff

    this.emit('complicatedAction', data, anotherData);
}

##To create a store

import {Store} from 'no-react-reflux';

import ExampleAction from '../actions/ExampleAction';

class ExampleStore extends Store {
    constructor() {
        super();

        ExampleAction.addListener('actionName', this.onActionName.bind(this));
        ExampleAction.addListener('complicatedAction', this.onComplicatedAction.bind(this));
    }

    onActionName(data) {
        // update store and emit event

        this.emit('event-name')
    }

    onComplicatedAction(data, anotherData) {
        // update store and emit change event

        this.trigger()
    }
}

export default new ExampleStore;
1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago