πΏοΈ π¦ Introduction to jods
"Got state to track? Just jods it down"
jods (JavaScript Object Dynamics System) is a fun, intuitive reactive state library that makes JavaScript objects come alive. Build lightweight stores that respond to changes, compute derived values, and keep your application state in sync.
π€ What is jods?β
jods is a tiny state management library designed to be simple, flexible, and powerful. It's perfect for:
- π Syncing app state
- π Powering APIs
- π¨ Building reactive UIs without heavy frameworks
β¨ Key Featuresβ
- βοΈ Zero dependencies
- π§ Computed values are built-in
- β‘ Works with React/Preact via useSyncExternalStore
- π· Built-in deep cloning with json()
- 𧬠Minimal API, no boilerplate actions or reducers
- π§ͺ Diff detection baked in
- π§© Framework agnostic, but integrates well with React/Preact
π¦ Installationβ
npm install jods
π± Basic Usageβ
import { store, json, onUpdate, computed } from "jods";
const user = store({
firstName: "Burt",
lastName: "Macklin",
mood: "curious",
});
// Subscribe to changes
onUpdate(user, (newUserState) => {
console.log("User state updated:", json(newUserState));
});
// Mutate existing fields
user.firstName = "Burt Macklin";
user.mood = "sneaky";
// Add new computed field
user.fullName = computed(() => `${user.firstName} ${user.lastName}`);
console.log(json(user));
// { firstName: "Burt Macklin", lastName: "Macklin", mood: "sneaky", fullName: "Burt Macklin Macklin" }
π Why Choose jods?β
jods takes state management back to basics. It provides a simple, intuitive API that feels like working with regular JavaScript objects, while adding powerful reactive capabilities.
Ready to learn more? Let's explore jods in depth. π πΏοΈ π¦