Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Teeny Tiny State — a 0.5 KB reactive state utility for JavaScript.

NotificationsYou must be signed in to change notification settings

zhuravkovigor/teeny-tiny-state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npmbundle size

A teeny tiny reactive stateutility for JavaScript — lighter than a feather (0.5 KB).

Minimal, fun, and only what you really need to make your state reactive.


✨ Features

  • 🪶 Super lightweight & minimal
  • 🔄 Reactive state with automatic updates
  • 📦 Works with objects and arrays
  • 🌐 Supports both ESM and UMD (browser <script> ready)

🚀 Usage

With ES Modules

import{reactive,effect}from"teeny-tiny-state";conststate=reactive({count:0});effect(()=>{console.log("Count is:",state.count);});state.count++;// triggers effect -> "Count is: 1"

With Arrays

import{reactive,effect}from"teeny-tiny-state";conststate=reactive({items:[]});effect(()=>{console.log("Items:",state.items.join(", "));});state.items.push("Hello");// Items: Hellostate.items.push("World");// Items: Hello, World

In the Browser

<scriptsrc="./dist/teeny-tiny-state.umd.js"></script><script>const{ reactive, effect}=TeenyTinyState;conststate=reactive({count:0});effect(()=>{document.body.textContent=`Count:${state.count}`;});setInterval(()=>state.count++,1000);</script>

With cleanup

import{reactive,effect}from"teeny-tiny-state";conststate=reactive({count:0});effect(()=>{consttimer=setInterval(()=>{console.log("Tick:",state.count);},1000);return()=>clearInterval(timer);});state.count++;

🛠 API

reactive(object)

Wraps an object or array into a reactive proxy.All reads and writes will be tracked automatically.

effect(fn)

Registers a reactive effect function.The function will automatically re-run whenever its dependencies change.

About

Teeny Tiny State — a 0.5 KB reactive state utility for JavaScript.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp