Skip to main content

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?​

WatchFieldOptions

ΠžΠΏΡ†ΠΈΠΈ

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
});
}
});
};