alibaba / formily

📱🚀 🧩 Cross Device & High Performance Normal Form/Dynamic(JSON Schema) Form/Form Builder -- Support React/React Native/Vue 2/Vue 3
https://formilyjs.org/
MIT License
11.12k stars 1.44k forks source link

[Bug Report] observer观察一个compouted对象。无响应式。 #3958

Open Likj opened 10 months ago

Likj commented 10 months ago

Reproduction link

Edit on CodeSandbox

Steps to reproduce

'use strict'; const { observe, observable, autorun } = require("@formily/reactive");

const originData1 = observable({ firstKey: { secondKey: { resultKey: 1 } } });

const originData2 = observable({ firstKey: { secondKey: { resultKey: 1 } } });

const computedData = observable.computed(() => { return ( originData1.firstKey.secondKey.resultKey + originData2.firstKey.secondKey.resultKey ); });

/**

console.log("开始运行");

originData2.firstKey.secondKey.resultKey = 2; originData2.firstKey.secondKey.resultKey = 3; originData2.firstKey.secondKey.resultKey = 4;

What is expected?

预期obserer函数能正常观察computed对象。并且具备相应式。

What is actually happening?

obserer函数无法对computed对象具备相应式。

Package

@formily/reactive@2.2.29


atom-set commented 10 months ago

添加autorun(() => computedData.value);即可

image