Brandon Brandon - 1 year ago 101
Javascript Question

Do methods on Immutable.js Records replicate?

My app loads about 30-50 instances of an

Immutable.js Record
. I'd like to write a
that applies a few operations to the data before returning it.

Is this efficient? Or will I end up with 30-50 copies in-memory of any method I write?


This is my current pattern:

export const EntityRecord = Immutable.Record({
// key/values

class Entity extends EntityRecord {

getProp() {
return this.get('property')


Answer Source

It depends on the implementation. You could simply write a utility method

export function myRecordGetter(myRecord) {
   ... do your work here ....
   return thingYouComputed;

Then just import and call it. If you plan to "extend" the functionality of a record, it depends on how you do it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download