🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

fluxstore2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluxstore2

Store class for facebook flux, generates event methods automatically, more simple dispatch listener

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

fluxstore

Store class for facebook flux, generates event methods automatically, more simple dispatch listener

Generates for you these methods:

addYourEventListener, removeYourEventListener, emitYourEvent

With this module you can write store this way::

const AppDispatcher = require('../dispatcher/app_dispatcher');
const SampleConstants = require('../constants/sample_constants');
const FluxStore = require('fluxstore')

class SampleStore extends FluxStore {
  getEvents() {
    return ['create', 'change', 'createError', 'addTag'];
  }
  create(data) {
    // ...
  }

  addTag(linkId, tag) {
    // ...
  }



  getAll() {
    // ...
  }

  destroy(link) {
    // ...
  }

  connections(connect) {
    connect(SampleConstants.SAMPLE_CREATE, (action) => {
      this.create(action.data);
      this.emitChange();
      this.emitCreate();
    });
    connect(SampleConstants.SAMPLE_CREATE_ERROR, this.emitCreateError);
    connect(SampleConstants.SAMPLE_DESTROY, this.destroy);
    connect(SampleConstants.SAMPLE_ADD_TAG, ({link, tag}) => {
      this.addTag(link.id, tag);
      this.emitChange();
      this.emitAddTag();
    });
  }

};

let store = new SampleStore(AppDispatcher);

module.exports = store;

and in your component:


var SampleComponent = React.createClass({
  /// ...
  componentDidMount: function() {
    SampleStore.addChangePathListener(this._onChangePath);
    SampleStore.addAddTagListener(this._onAddTag);
    SampleStore.addMobileUpdateListener(this._onMobileUpdate);
  },
  componentWillUnmount: function() {
    SampleStore.removeChangePathListener(this._onChangePath);
    SampleStore.removeAddTagListener(this._onAddTag);
    SampleStore.removeMobileUpdateListener(this._onMobileUpdate);
  },
  /// ...
})

Keywords

flux

FAQs

Package last updated on 25 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts