๐—›๐—ผ๐˜„ ๐—œ ๐—•๐˜‚๐—ถ๐—น๐˜ ๐—ฎ ๐—ฅ๐—ฒ๐—ฎ๐—ฐ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฆ๐˜๐—ฎ๐˜๐—ฒ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ ๐—ถ๐—ป ๐—ฃ๐˜‚๐—ฟ๐—ฒ ๐—๐—ฎ๐˜ƒ๐—ฎ๐—ฆ๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜

Building Levelo JS forced me to solve a hard problem. I needed a reactive state system.

My first plan felt like React. I wanted developers to access state values directly. I planned to use a getter and setter system. On paper, it looked easy. In practice, it was hard.

The framework must track three things:

Managing these tasks without adding mess is difficult. I spent time fighting the complexity.

I stopped chasing a perfect solution. I decided to build a working MVP instead. I tried a function-based approach.

The new API looks like this:

import { state } from 'levelojs';

function Counter() { const [count, setCount] = state(0);

return ( // UI ); }

This design works better. It is closer to SolidJS than React. It makes the code cleaner. It makes debugging faster.

I used AI to test different ideas during this process. I did not want to copy others. I wanted to understand how reactivity works under the hood.

This project taught me a lesson. Your first idea is not always the best idea. Many developers waste time on perfect solutions. A simple solution moves your project forward faster.

Reactivity is not magic. It is the result of design and problem solving.

If you build a library, choose the simple path first. You can improve it later.

Source: https://dev.to/motionmind2007/how-i-built-a-reactive-state-system-in-pure-javascript-1lj