包详细信息

valtio-reactive

valtiojs1.7kMIT0.1.2

valtio-reactive makes Valtio a reactive library

valtio, reactive

自述文件

valtio-reactive

CI npm size discord

valtio-reactive makes Valtio a reactive library

Background

See: https://github.com/pmndrs/valtio/discussions/949

Install

npm install valtio valtio-reactive

Usage

import { proxy } from 'valtio/vanilla';
import { batch, computed, effect } from 'valtio-reactive';

const state = proxy({ count: 1 });

const derived = computed({
  double: () => state.count * 2,
});

effect(() => {
  console.log('double count:', derived.double);
});

setInterval(() => {
  batch(() => {
    state.count++;
    state.count++;
  });
}, 1000);

更新日志

Change Log

[Unreleased]

[0.1.2] - 2025-03-10

Changed

  • fix: watch for structural changes on objects and arrays #3

[0.1.1] - 2024-11-22

Changed

  • fix: sync effect by default #1

[0.1.0] - 2024-11-22

Added

  • Initial release