A few years ago, I needed a module to maintain a complex and multi-layered application state of a react-based desktop app and its underlying infra. Then I realized I needed more than a passive state-management lib --Turing complete and concurrent agents capable of resolving the chaotic asynchronous inputs and signals.<p>Vaettir is an agent writing library, and Vaettir-React binds the agents to invert the control of a React application.
Instead of piping user-generated events into `setState` and `useEffect` hooks (which often grow unmaintainable past a certain complexity threshold), Vaettir agents can optionally run on their own, typically by means of async loops. It is written similarly to multi-threaded programs written in lower-level languages. A simple abstract example is an agent that pools concurrent user and network events (e.g. clicking things while the app is fetching for something), merging these incoming requests, and then processing them sequentially.<p>Vaettir agents can be passed into many components either via props or context. As a side-effect, it can be used as a state-management library with flexible scoping.
Its custom channels can be subscribed by different React components, allowing for semantically meaningful selective re-rendering.
Last but not least, provided optional hooks bind the agent's and the component's lifetime (i.e. when mounted, the agent is created; when unmounted, the agent is destroyed), optionally with a `[dependency, array]` style of `useEffect` hooks.