I understand that this image has been the ultimate guide of most, if not all, Flux programmers. Having this flow in mind, I have a few questions:
- Is it correct/highly advisable to have all of my
$.ajax
calls inside my Web API Utils?- Callbacks call the action creators, passing the data in the process
- If I want my Store to make an AJAX call, I do have to call the Action Creator first, right? Is it fundamentally incorrect to call a function in Web API Utils directly from Store?
- Is there like a virtual one-sided arrow connecting from Store to Action Creators?
- I have a lot of operations that do not go through views
- What are the Callbacks between Dispatcher and Store?
- What's the Web API here? Is this where you'd apply a RESTful API? Is there an example of this somewhere?
Is it okay to have a logic involved (to know which Action to dispatch) in one of my Action Creators? Basically, this action receives the response from my AJAX call. This is a snippet:
var TransportActions = { receiveProxyMessage: function (message, status, xhr) { switch (message) { case ProxyResponses.AUTHORIZED: AppDispatcher.dispatch({ type: ActionTypes.LOGIN_SUCCESS, reply: m }); break; case ProxyResponses.UNAUTHORIZED: AppDispatcher.dispatch({ type: ActionTypes.LOGIN_FAIL, reply: m }); break; ... } } }
I've seen a lot of different answers online, but I am still not sure how I would incorporate all of them in my application. TYIA!