How to use the reflux.listenTo function in reflux

To help you get started, we’ve selected a few reflux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shalomeir / snippod-boilerplate / snippod_webapp / client / scripts / components / authentication / Login.jsx View on Github external
Router = require('react-router'),
    { Link } = Router,
    // components
    Spinner = require('../commons/Spinner.jsx'),
    // stores
    AuthStore = require('../../stores/authentication/AuthStore'),
    ComponentMessageStore = require('../../stores/subs/ComponentMessageStore'),
    // actions
    AuthAccountActions = require('../../actions/authentication/AuthAccountActions');


var Login = React.createClass({

  mixins: [
    PureRenderMixin,
    Reflux.listenTo(AuthStore, 'resetForm'),
    Reflux.listenTo(ComponentMessageStore, 'onErrorMessage'),
  ],

  getInitialState: function() {
    return {
      loggedIn: false,
      errors: '',
      submitted: false
    };
  },

  resetForm: function() {
    var auth = AuthStore.getAuth();
    if(this.state.loggedIn !== auth.loggedIn){
      this.refs.email.getDOMNode().value = '';
      this.refs.password.getDOMNode().value = '';
github shalomeir / snippod-boilerplate / snippod_webapp / client / scripts / components / authentication / Register.jsx View on Github external
Router = require('react-router'),
    { Link } = Router,
    // components
    Spinner = require('../commons/Spinner.jsx'),
    // stores
    AuthStore = require('../../stores/authentication/AuthStore'),
    ComponentMessageStore = require('../../stores/subs/ComponentMessageStore'),
    // actions
    AuthAccountActions = require('../../actions/authentication/AuthAccountActions');


var Register = React.createClass({

  mixins: [
    PureRenderMixin,
    Reflux.listenTo(AuthStore, 'resetForm'),
    Reflux.listenTo(ComponentMessageStore, 'onErrorMessage')
  ],

  getInitialState: function() {
    return {
      errorPrescriptions: null,
      errors: null,
      submitted: false
    };
  },

  resetForm: function() {
    this.refs.email.getDOMNode().value = '';
    this.refs.username.getDOMNode().value = '';
    this.refs.password.getDOMNode().value = '';
    this.refs.confirmPassword.getDOMNode().value = '';
github coodict / coodict.com / app / components / AceEditor.jsx View on Github external
var ace         = require('brace');
var React       = require('react');
var Reflux      = require('reflux');
var editorStore = require('../stores/editorStore');
var spellStore  = require('../stores/spellStore');


// Setup module url
var ACE_HOST = 'http://webapi.coodict.com/brace/mode/';
for (var k in require('../mixins/lang').MODE_LABEL_MAP) {
  ace.config.setModuleUrl('ace/mode/'+k, ACE_HOST+k+'.js');
}

var AceEditor = React.createClass({
  mixins:[
    Reflux.listenTo(editorStore, 'changeMode'),
  ],
  getValue: function(){
    return this.editor.getValue();
  },
  changeMode: function(lang){
    this.setState({
      mode: lang.mode,
    });
    // this.editor.setValue(this.props.value, 1);
    this.editor.getSession().setMode({
      path: 'ace/mode/' + lang.mode,
      v: Date.now()
    })
  },
  propTypes: {
    name:     React.PropTypes.string,
github mjibson / moggio / server / static / src / group.js View on Github external
function group(route, field, name) {
	return React.createClass({
		mixins: [Reflux.listenTo(Stores.tracks, 'setState')],
		getInitialState: function() {
			return Stores.tracks.data || {};
		},
		render: function() {
			var entries = {};
			_.each(this.state.Tracks, function(val) {
				var f = val.Info[field];
				if (f) {
					entries[f] = true;
				}
			});
			var list = _.keys(entries);
			list.sort(function(a, b) {
				return a.toLowerCase().localeCompare(b.toLowerCase());
			});
			var lis = _.map(list, function(val) {
github BoostIO / Boostnote / browser / main / Mixins / KeyCaster.js View on Github external
module.exports = function (stateKey) {
  return {
    mixins: [Reflux.listenTo(KeyStore, 'onKeyCast')],
    componentDidMount: function () {
      var newState = {}
      newState[stateKey] = true
      KeyStore.setState(newState)
    },
    componentWillUnmount: function () {
      var newState = {}
      newState[stateKey] = false
      KeyStore.setState(newState)
    }
  }
}

reflux

A simple library for uni-directional dataflow application architecture inspired by ReactJS Flux

BSD-3-Clause
Latest version published 8 years ago

Package Health Score

59 / 100
Full package analysis