I'm porting a big Reduxless React application to Redux and I'm not sure how to handle initialisation of the app.
At start the app fetches all the URLs required for it to work so every other fetch after the first one actually uses these URLs. During the lifetime of the application itself they never change, they're all static yet I have to get them dynamically because they might change from time to time.
So I'm fetching, let's say, 150 URLs, and here's my question - where should I store them?
1. Redux
Putting the URLs to Redux storage makes sense at first but then I noticed I'd use these urls in action creators almost exclusively and it's considered an anti-pattern as far as I know (see top rated reply here why). I even tried accessing them in action creators but it was a hassle.
2. Global variable
Making the first call outside of Redux and storing my global variables in an easy to reach place such as window.MyAppNameConfig.urls
makes sense but what if I dispatch some Redux actions before the global variable is set? I'm doomed. Maybe I could check somehow if the variables are set and then repeat dispatches? But it sounds quite complicated.
3. Redux + global variable
Maybe it would be possible (I'm using redux-axios-middleware
) to dispatch getTheUrls action and then instead of pushing it to the store - save it as a variable? Not sure if this is a good idea and I'm not really sure how to achieve that (I'm only learning Redux), if no, why not?
Thanks for any input.