Looking at this, I think that Immutable. Record is the data structure for represent "javascript immutable objects", but I want to update several fields at once without creating several objects calling set each time.
I want to do something like this
class LoginContext extends Immutable.Record(
{ logged : false, loading: false, error: false, user: null}){
}
var loginContext = new LoginContext()
var anotherContext = loginContext.set({'logged':'true', 'error':'false'})
I read that you can't pass an object to Record.set() for API consistency:
Consistency with other uses of set both in this library and in ES6. Map and Set's set can't accept an object, because their keys can be anything, not just strings. Records must have strings, but keeping the API consistent was important.
And I know that I could use:
var anotherContext = loginContext.withMutations(function (record) {
record.set('logged','true').set('error','true');
});
There is another way or I'm misusing Record?