Reacting to laoded data part 2
• Mark Eschbach
Alrighty, I’ve got a few minutes here. Last night I left off with the data loading. Now the drawer needs to respond by updating with the information. Simple enough once I got all of the elements in line. From the standpoint of the application state, I have a root reducer subjects
which maintains a map of IDs to data. There are two meta fields: loaded
and loading
, used to describe the acquisition state. Probably would have been better to store a time there, but meh.
Now that the drawer works as I expect it’s time to being work on the user dashboard. The primary use case is removing or update credentials, which can bee federated with Google and Facebook. Each of the credential entities will have their own reducers + actions to retrieve the data. Should be simple enough. I’ll work on retrieval first.
This whole ES6 Class thing is kind of a drag given Redux’s desire to have a function. I have to declare a strange name then connect and store a reference to the augmented component. I suppose this would be the reasoning behind having views and containers. I’m tempted to try this approach intead of the functional component approach right now because I’m not sure about hte lifecycle integration. Let’s find out how the view and container paradigm works for me.
Extracting the method for loading a subject has become problematic. I could load the information twice however this makes me a little unhappy. What I really need is a component which will interpret the state to see if the user should be loaded. For now, despite being an antipattern I’m going to pass state in too. I still don’t want to pull in react-thunk
although I feel like I have a better knowledge base to understand it’s problem domain. In a StackOverflow query asking a similar question they recommend yet another library, this time from Facebook. Of course React + Redux has a realworld example which offers an example of how to setup their system. I’m hoping it was better than the method I tried. Found an (Angular + Redux tutorial)[https://www.bennadel.com/blog/2995-managing-locally-cached-data-with-redux-in-angularjs.htm] which I would like to try at some point, probably pretty awesome combination. All well, out of time. To come back to later.