How to use the prairie.mergeWith function in prairie

To help you get started, we’ve selected a few prairie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cape-io / redux-field / src / reducer.js View on Github external
initialValue: null, // Anything.
  invalid: {}, // index of invalid values.
  meta: null, // Anything.
  savedProgress: 0, // Percentage Number 0-99.
  savedValue: null,
  isSaving: false, // Bool.
  isTouched: false,
  valid: {}, // index of valid values.
  value: null, // Anything.
}

export const resetFields = fields => mergeWith(pick(fields, defaultState))

export const getDragCount = get('dragCount')

export const setFocus = mergeWith({ blur: false, focus: true, isTouched: true })
export const setClose = resetFields(['blur', 'focus'])

export const saving = set('isSaving', true)
export const isNewValue = (state, payload) => (!isUndefined(payload) && payload !== state.value)
export const setValue = overBranch(isNewValue, setIn('value'))
export const touched = overBranch(negate(get('isTouched')), set('isTouched', true))
export const changeReducer = flow(setValue, touched)

export const blurReducer = flow(
  changeReducer,
  resetFields(['dragCount', 'focus']),
  set('blur', true),
)

export const closeReducer = flow(setClose, touched)
github cape-io / redux-field / src / reducer.js View on Github external
export const resetFields = fields => mergeWith(pick(fields, defaultState))

prairie

Add/Modify fields on an object with composable functions.

ISC
Latest version published 1 year ago

Package Health Score

46 / 100
Full package analysis

Popular prairie functions