watchField()
function watchField<TForm, TField>(
field,
callback,
options?): void;
Defined in: core/behavior/behaviors/watch-field.ts:39
Выполняет callback при изменении поля
Type Parameters
TForm
TForm
TField
TField
Parameters
field
FieldPathNode<TForm, TField>
Поле для отслеживания
callback
(value, ctx) => void | Promise<void>
Функция обратного вызова
options?
Опции
Returns
void
Example
const schema: BehaviorSchemaFn<MyForm> = (path) => {
// Динамическая загрузка городов при изменении страны
watchField(path.registrationAddress.country, async (country, ctx) => {
if (country) {
const cities = await fetchCities(country);
ctx.updateComponentProps(path.registrationAddress.city, {
options: cities
});
}
});
};