Answer the question
In order to leave comments, you need to log in
How to overcome synchronous requests in the Flux dispatcher?
The flux architecture uses a dispatcher that can only work synchronously. Therefore, in large applications, it happens that actions occur in the dispatcher and cause an error.
Of course, you can make several dispatchers, but something tells me that this is not the best option, although maybe I didn’t understand it properly.
Therefore, the question is:
How to make the Flux architecture correctly, so that actions do not occur in the dispatcher, for a large single-page application?
Answer the question
In order to leave comments, you need to log in
It's really strange how they can intersect. Well, okay, take the documentation, everything is written there quite well, the meaning is this, you have a Dispatcher.
Create class App.Dispatcher.js (everything will be in ES6):
import {Dispatcher} from 'flux';
export default new Dispatcher();
import AppDispatcher from './AppDispatcher.js';
export default {
firstAction(){
AppDispatcher.dispatch({
actionType: 'FIRST__ACTION'
});
},
secondAction(){
AppDispatcher.dispatch({
actionType: 'SECOND__ACTION'
});
}
}
import AppDispatcher from './AppDispatcher.js';
export default class AppStore {
constructor() {
AppDispatcher.register(function (action) {
switch (action.actionType) {
case 'FIRST__ACTION':
//Первое действие
break;
case 'SECOND__ACTION':
//Второе действие
break;
}
});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question