React Flux Webpack



  • Trying to build an extremely simple CRUD app with Flux. Why is this console.log not working in my ServerStore.js register function? It seems like webpack is not even bundling it?

    ServerStore.js

    var AppDispatcher = require('../dispatcher/dispatcher');
    var AppConstants = require('../actions/constants');
    var assign = require('react/lib/Object/assign');
    var EventEmitter = require('events').EventEmitter;

    var CHANGE_EVENT = 'change';

    var ServerStore = assign(EventEmitter.prototype, {
    emitChange: function(){
    this.emit(CHANGE_EVENT)
    },
    addChangeListener:function(callback){
    this.on(CHANGE_EVENT, callback)
    },
    removeChangeListener: function(callback){
    this.removeListener(CHANGE_EVENT, callback)
    },

    });
    AppDispatcher.register(function(payload){
    var action = payload.action;
    console.log('hhhhhhhhhhh'); //<----------------NOT WORKING!

    });
    Dispatcher.js

    var Dispatcher = require('flux').Dispatcher;
    var assign = require('react/lib/Object.assign');

    var AppDispatcher = assign(new Dispatcher(), {
    handleViewAction: function(action){
    console.log('action', action)//<------THIS WORKS OK!
    this.dispatch({
    source:'VIEW_ACTION',
    action: action
    })
    }
    });

    module.exports = AppDispatcher;
    webpack.config.js

    module.exports ={
    entry: "./app-client.js",
    output: {
    filename: "public/bundle.js"
    },
    module:{
    loaders:[
    {
    exclude: /(node_modules|app-server.js)/,
    loader: 'babel'
    }
    ]
    }
    };


  • f.lux team

    I think you are thinking of Facebook Flux, not f.lux here.


Locked