mercredi 4 janvier 2017

Use pair of objects as key, pass them to their property's constructor, without a hashing layer

How can I meet all of these requirements?

  1. eliminate the extra level of nesting
  2. eliminate the required constructor params node0 and node1
  3. use valid Javascript
  4. prioritize ease of use (no custom hashing function)

BAD

let interactions = {
    node0: {
        node1: {
            physics: new PhysicsReducer(node0, node1, config);
        }
    }
};

GOOD

let interactions = {
    [node0, node1]: {
        physics: new PhysicsReducer(config)
    }
};


Thanks

Aucun commentaire:

Enregistrer un commentaire