@roqueform/reset-plugin
TypeScript icon, indicating that this package has built-in type declarations

4.1.0 • Public • Published

Reset plugin for Roqueform

Manages Roqueform field initial value and dirty status.

npm install --save-prod @roqueform/reset-plugin

Overview

🔎 API documentation is available here.

Update the initial value of a field:

import { createField } from 'roqueform';
import { resetPlugin } from '@roqueform/reset-plugin';

const planetField = createField({ name: 'Pluto' }, resetPlugin());

planetField.setInitialValue({ name: 'Mars' });

planetField.at('name').initialValue;
// ⮕ 'Mars'

The field is considered dirty when its value differs from the initial value. Values are compared using an equality checker function passed to the resetPlugin. By default, values are compared using fast-deep-equal.

planetField.at('name').isDirty // ⮕ true

Get the array of all dirty fields:

planetField.getDirtyFields();
// ⮕ [planetField.at('name')]

Package Sidebar

Install

npm i @roqueform/reset-plugin

Weekly Downloads

15

Version

4.1.0

License

MIT

Unpacked Size

9.22 kB

Total Files

8

Last publish

Collaborators

  • smikhalevski