javascript - Reflux stores not listening to actions -


edit:

i feel silly now. the problem wasn't requiring store anywhere in code, never being created.

my refluxjs store not calling callback when call action it's listening to. here relevant code:

actions:

module.exports = require("reflux").createactions([     "createuser" ]); 

store:

var useractions = require("../actions/user-actions");  module.exports = require("reflux").createstore({     listenables: useractions,      oncreateuser: function() {         console.log("oncreateuser called", arguments);     } }); 

component fires action:

var react = require("react"),     useractions = require("../../actions/user-actions");  var login = react.createclass({     getinitialstate: function() {         return {             name: ""         };     },      updatename: function(event) {         this.setstate({             name: event.target.value         });     },      // action gets called here     submit: function(event) {         event.preventdefault();         console.log("creating user", this.state.name);         useractions.createuser(this.state.name);     },      render: function() {         var name = this.state.name;          return (             <div classname='login'>                 <form onsubmit={this.submit}>                     <input value={name} onchange={this.updatename} />                     <button>create</button>                 </form>             </div>         );     } }); 

when submit form in login component, submit method called without throwing errors, oncreateuser method of store never called.

the examples on reflux github page seem straightforward , same example using listenables property on store.

any appreciated.

since stores hooked component, , required in way, create test component logs out console:

var store = require('path/to/your/store'),     react = require('react'),     reflux = require('reflux');  var consolelogcomponent = react.createclass({     mixins: [          reflux.listento(store, "log")         // may add more stores here calls log method     ],     log: function() {         console.log(arguments);     },     render: function() {         return <div />     } }); 

you can put console component ever , have sanity check store works.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -