Bu sahifa hali tarjima qilinmagan
Tarjima qoshish uchun havola boyicha o'tib Pull Request oching (havolaga o'tish).
Standart til uchun tarkibni ko'rsatadi.
import { createWatch } from "effector";
Methods
createWatch(config)
Creates a subscription on unit (store, event, or effect).
Formulae
createWatch<T>(config: {
unit: Unit<T>
fn: (payload: T) => void
scope?: Scope
}): Subscription
Arguments
config
(Object): Configurationunit
(Unit): Target unit (store, event of effect) that will be watchedfn
(Function): Function that will be called when the unit is triggered. Accepts the unit’s payload as the first argument.scope
(Scope): An optional scope object (forked instance) to restrict watcher calls on particular scope.
Returns
Subscription: Unsubscribe function
Examples
With scope
import { createWatch, createEvent, fork, allSettled } from "effector";
const changeName = createEvent();
const scope = fork();
const unwatch = createWatch({ unit: changeName, scope, fn: console.log });
await allSettled(changeName, { scope, params: "John" }); // output: John
changeName("John"); // no output
Without scope
import { createWatch, createEvent, fork, allSettled } from "effector";
const changeName = createEvent();
const scope = fork();
const unwatch = createWatch({ unit: changeName, fn: console.log });
await allSettled(changeName, { scope, params: "John" }); // output: John
changeName("John"); // output: John
Tarjima jamiyat tomonidan qollanilyapti
Ingliz tilidagi hujjatlar eng dolzarb hisoblanadi, chunki u effector guruhi tomonidan yozilgan va yangilanadi. Hujjatlarni boshqa tillarga tarjima qilish jamiyat tomonidan kuch va istaklar mavjud bo'lganda amalga oshiriladi.
Esda tutingki, tarjima qilingan maqolalar yangilanmasligi mumkin, shuning uchun eng aniq va dolzarb ma'lumot uchun hujjatlarning asl inglizcha versiyasidan foydalanishni tavsiya etamiz.