UNPKG

valtio-reactive

Version:

valtio-reactive makes Valtio a reactive library

15 lines (14 loc) 425 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.computed = computed; const vanilla_1 = require("valtio/vanilla"); const core_js_1 = require("./core.js"); function computed(obj) { const computedState = (0, vanilla_1.proxy)({}); for (const key in obj) { (0, core_js_1.watch)(() => { computedState[key] = obj[key](); }); } return computedState; }