f.lux f.lux forum
    • Recent
    • Popular
    • Register
    • Login

    React Flux Webpack

    Windows v4
    2
    2
    703
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jaisongomes
      last edited by

      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'
      }
      ]
      }
      };

      1 Reply Last reply Reply Quote 0
      • herfH
        herf
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors