An open API service indexing awesome lists of open source software.

https://github.com/xaviergonz/mobx-bonsai

A fast lightweight alternative to MobX-State-Tree + Y.js two-way binding
https://github.com/xaviergonz/mobx-bonsai

mobx mobx-keystone mobx-node mobx-state-tree observable state-management yjs

Last synced: about 1 year ago
JSON representation

A fast lightweight alternative to MobX-State-Tree + Y.js two-way binding

Awesome Lists containing this project

README

          



mobx-bonsai


A fast lightweight alternative to MobX-State-Tree + Y.js two-way binding



















> ### Full documentation can be found on the site:
>
> ## [mobx-bonsai.js.org](https://mobx-bonsai.js.org)

## Introduction

A fast lightweight alternative to `mobx-state-tree` that combines the simplicity of plain data with the power of MobX reactivity. Unlike `mobx-state-tree`, tree nodes in `mobx-bonsai` are always plain data objects with no embedded methods, getters, or setters. Instead, all interactions are managed via external functions—getters and MobX actions like embracing a more functional approach, thus improving performance and memory usage. Your application state remains a simple, observable plain object. Instead of modifying the nodes directly with object methods, you work with pure functions that inspect or update the state, ensuring clarity and reproducibility.

By using `mobx-bonsai`, you get:

- **Lightweight and fast:** Optimized for performance while consuming less memory.
- **Functional accessors:** Interaction is achieved through pure functions, keeping state manipulation decoupled from the data structure.
- **Immutable snapshots:** Effortlessly capture a stable state of your tree at any point.
- **MobX Integration:** Since `mobx-bonsai` uses MobX behind the scenes, it integrates seamlessly with [`mobx`](https://mobx.js.org) and [`mobx-react`](https://github.com/mobxjs/mobx-react).
- **Seamless Y.js binding:** Two-way binding between `Y.js` state trees and `mobx-bonsai` reactive trees included.

### Installation

> `npm install mobx-bonsai`

> `yarn add mobx-bonsai`