withRegion(unit: Unit<T> | Step, cb: () => void)

The method allow to explicitly transfer ownership of all units (including links created with sample, forward, etc..) defined in the callback cb to unit. As an implication all the created links will be erased as soon as clearNode will be called on unit.

The method is based on the idea of region-based memory managment (see https://en.wikipedia.org/wiki/Region-based_memory_management for reference)


  1. unit: Unit | Step which will serve as "local area" or "region" owned all the units created within provided callback cb
  2. cb: () => void Callback where all the relevant units should be defined


import {createDomain, createEvent, restore, withRegion, clearNode} from 'effector'
const first = createEvent()
const second = createEvent()
const store = restore(first, '')
const domain = createDomain()
withRegion(domain, () => {
// Following links created with `forward` or `sample` are owned by provided unit `domain`
// and will be disposed as soon as `clearNode` would be called on `domain`
from: second,
to: first,
second('will not trigger updates of `store`')
Last updated on