Skip to content

Commit fdcc95b

Browse files
committed
Clarify the limitations
1 parent 19ba2aa commit fdcc95b

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,32 @@ While `Date` serializes fine, **avoid storing `Set` or `Map`** directly in globa
193193

194194
## 🚧 Known Limitations
195195

196-
Kosha is intentionally minimal, and with that comes tradeoffs:
196+
Kosha is intentionally minimal by designbuilt to offer just what most React apps need, without bloat. That comes with a few tradeoffs:
197197

198-
- **Selector Comparison via `JSON.stringify`**: Fast and reliable for most use cases, but not suitable for diffing non-serializable objects like `Set`, `Map`, or very large/deep objects. Having said that, it works excellently well with moderately large/deep objects
199-
- **Limited Built-in Plugins**: Middleware architecture is in place, but plugin ecosystem is early. You can write your own `devtools`, etc.
198+
### 🧠 Selector Comparison via `JSON.stringify`
199+
200+
Kosha uses `JSON.stringify` internally to compare selector outputs for change detection. This works extremely well for the majority of caseseven with moderately large or deeply nested selectors.
201+
202+
However, there are a few caveats:
203+
204+
- **Avoid non-serializable values** in selectors like `Set`, `Map`, `WeakMap`, or circular objects.
205+
- **Very large selector outputs** may incur performance costs during diffing.
206+
207+
> To clarify:
208+
>Its perfectly fine to have a large store or global state.
209+
> ⚠️ What matters is the **output of your selector**. If youre selecting a large slice like `state => ({ a: state.a, ..., z: state.z })`, its more efficient to either:
210+
>
211+
> - Access the store directly without a selector (`useKosha()`), or
212+
> - Extract only the minimal fields you actually need.
213+
214+
### 🔌 Plugin Ecosystem Still Growing
215+
216+
Kosha includes full support for custom middleware and already ships with a working [persist middleware](https://github.com/mayank1513/kosha/blob/main/lib/src/middleware/persist.ts). However:
217+
218+
- Built-in plugins like `devtools` are not yet included.
219+
- A community-driven plugin ecosystem is still in its early stages.
220+
221+
> That said, the underlying architecture is solid and middleware-readyyou're free to build and compose your own middleware as needed.
200222

201223
---
202224

0 commit comments

Comments
 (0)