I began to study the architecture of Facebook Flux. I am trying to make a simple login screen. I created a flux-chat screen sample. I have a cyclical dependency problem between ServerActionCreator and WebAPIUtils. See code below.
ServerActionCreator.js
var AppDispatcher = require('../dispatcher/AppDispatcher'); var Constants = require('../constants/Constants'); var WebAPIUtils = require('../utils/WebAPIUtils'); var ActionTypes = Constants.ActionTypes; module.exports = { receiveLoginStatus: function(status){ AppDispatcher.handleServerAction({ type: ActionTypes.RECEIVE_LOGIN_STATUS, status: status }); }, loginSubmit: function(data){ WebAPIUtils.login(data); } }
WebAPIUtils.js
var ServerActionCreator = require('../actions/ServerActionCreator'); module.exports = { login: function (data) {
As you can see, ServerActionCreator depends on WebAPIUtils, and WebAPIUtils depends on ServerActionCreator.
I think, due to the cyclical dependency, WebAPIUtils becomes an empty object, and I get the error "undefined is not a function" when calling the loginSubmit function in ServerActionCreator. Screenshot below.

How to cope with this scenario? or is there an alternative way? Any help is greatly appreciated.
source share