Specialized Behavior
We'll cover the following...
Redux-ORM provides some very useful tools for dealing with normalized data, but it only has so much functionality built-in. Fortunately, it also serves as a great starting point for building additional functionality.
Serializing and Deserializing Data
As mentioned earlier, the Normalizr library is the de-facto standard for normalizing data received from the server. I’ve found that Redux-ORM can be used to mostly build a replacement for Normalizr. I added static parse()
methods to each of my classes, which know how to handle the incoming data based on the relations:
class Lance extends Model {
static parse(lanceData) {
// Because it's a static method, "this" refers to the class itself.
// In this case, we're running inside a subclass bound to the Session.
const {Pilot, Battlemech, Officer} = this.session;
// Assume our incoming data looks like:
//
...