Factoring the loading
• Mark Eschbach
At this point I’ve gotten my application up and running. I’m not terriably happy with the way I’m dealing with the logic within the components, as the
condition && <Tags>; but I’ll come back to those later. Right now I’m trying to
patch user names via the fetch. The request is succesfully sent however it’s without the body. I’m passing in the body but I have a funny feeling need to construct the JSON object in a specific way for it to be attached.
There are some great examples of parsing the response entity from JSON in the MDN documentation, but not one for the request entity. I gave up and just used
JSON.stringify. I was hoping there was a better solution but this works.
Moving on to the next task of reading the state back: I’m expirimenting with storing etntity events as opposed to a singular entity state. As an expiriment I’m at the recall point, need to render the state for the client. Since the backend is ruby I need to convert the event time to a unix time stamp for storage and ordering. My expierence says that milliseconds is the correct scale for this kind of storage. I’m surprised I didn’t add this earlier. Right, because aggreviatingly you must do
DateTime.now.strftime("%Q").to_i in order to store it as an integer. I’m really surprised they don’t just provide a simple
Anyway, I generally avoid sorting things in Ruby, but in this case I have a series of events which need to be replayed based on the timestamp. It’s been a while since I’ve dealt with the
<=> spaceship operator. Stack Overflow to the rescue!: A fairly standard reduction to zero comparison to determine the results. I found
sort_by to be a much better method of sorting, allowing for record to be reduced to a key for sorting.
In an attempt to clean up and refactor common code I extrated a helper for responding with a specific entity. This resulted in a CORS failure, looking like the issue is partially understood but worked fine before I extracted the response into a helper method. I wonder what strange patching is going on under the hood. Or alternatively, what I’m doing wrong with my helper. I can overlook this issue for now given the example in that issue.
I’ve just encountered the problem of repeating display elements in JSX. The most promising example seems to be the map suggesstion. I’m still such a n00b at React Stack Overflow is helping :-).
Federated Credentials look really interested. I’ll have to look into that furhter in the future.