試圖用Flux構建一個非常簡單的CRUD應用程序。爲什麼這個console.log不能在我的ServerStore.js註冊函數中工作?它似乎webpack甚至沒有捆綁它?React Flux Webpack
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'
}
]
}
};