Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createFormMount(
formApi: FormApi,
): Gate<{||}> {
const OnMount = createGate<{||}>('form mount')
OnMount.close.watch(() => formApi.reset())
return OnMount
}
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
}