Skip to content

Form.updateField: Use "update" function instead of "propsPatch" #182

@kettanaito

Description

@kettanaito

What

I suggest to at least try to change the behavior of Form.updateField to expose an updater function to update the requested field record.

Why

Right now propsPatch is an Object which gets converted to Immutable (1) and then merged (2) with the record via fieldRecord.merge(fromJS(propsPatch)). Those are two costly procedures and they should be avoided.

Exposing the requested fieldRecord inside a custom updater function would mean that that record can be modified right away, without conversion or merging. All the data needed for update is available to compose propsPatch, anyway.

How

this.updateField({
  fieldPath,
  updater: fieldRecord => fieldRecord
    .set('validatedSync', false)
    .set('validatedAsync', false) 
    .set('validSync', false)
    .set('validAsync', false)
});

Keynotes

  • See what will Form.updateField() do after the introduction of this change. Would it still be worthy to isolated into a separate method?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions