How to use the effector-react.createGate function in effector-react

To help you get started, we’ve selected a few effector-react 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 zerobias / effector / src / forms / react / createFormMount.js View on Github external
export function createFormMount(
  formApi: FormApi,
): Gate<{||}> {
  const OnMount = createGate<{||}>('form mount')
  OnMount.close.watch(() => formApi.reset())
  return OnMount
}
github zerobias / effector / src / forms / react / createFieldGate.js View on Github external
export function createFieldGate(
  formApi: FormApi,
): $ObjMap(V) => Gate<{|value: V|}>> {
  const gate: {[key: string]: Gate<{|value: any|}>, ...} = {}
  const fields = formApi.values.getState()
  for (const key in fields) {
    gate[key] = createGate(key)
    gate[key].state.watch(({value}) => {
      if (value) formApi.api[key](value)
    })
  }
  return gate
}