Tarjima qoshish uchun havola boyicha o'tib Pull Request oching (havolaga o'tish).
Standart til uchun tarkibni ko'rsatadi.
import { withRegion } from "effector";
The method is based on the idea of region-based memory management (see Region-based memory management for reference).
Methods
withRegion(unit, callback)
The method allows to explicitly transfer ownership of all units (including links created with sample
, forward
, etc…) defined in the callback to unit
. As an implication, all the created links will be erased as soon as clearNode
is called on Unit.
Formulae
withRegion(unit: Unit<T> | Node, callback: () => void): void
Arguments
unit
: Unit | Node — which will serve as “local area” or “region” owning all the units created within the provided callback. Usually a node created by low levelcreateNode
method is optimal for this case.callback
:() => void
— The callback where all the relevant units should be defined.
Examples
import { createNode, createEvent, restore, withRegion, clearNode } from "effector";
const first = createEvent();
const second = createEvent();
const $store = restore(first, "");
const region = createNode();
withRegion(domain, () => {
// Following links created with `sample` are owned by the provided unit `domain`
// and will be disposed as soon as `clearNode` is called on `domain`.
sample({
clock: second,
target: first,
});
});
$store.watch(console.log);
first("hello");
second("world");
clearNode(region);
second("will not trigger updates of `$store`");
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.