Skip to content

Instantly share code, notes, and snippets.

@revanth0212
Created August 5, 2018 17:06
Show Gist options
  • Save revanth0212/28d229cb11222f4eba34448d40fbd165 to your computer and use it in GitHub Desktop.
Save revanth0212/28d229cb11222f4eba34448d40fbd165 to your computer and use it in GitHub Desktop.
A sample to show how to use the field changes calculator.
const calculator = require('field-change-effects-calculator');
const changesCalculator = calculator(rules);
const calculateChanges = (event) => {
const state = getState()
const { name, value } = event.target
const changes = changesCalculator(state)(name, ['path', 'of', 'field', 'in', 'the', 'state', 'object'], value)
return changes
}
// HTML
<input type="text" name="country" onBlur="calculateChanges()" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment