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