[Bug Report] observer观察一个compouted对象。无响应式。
- Dominant language
- TypeScript
- Stars
- 12.6k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
- [x] I have searched the [issues](https://github.com/alibaba/formily/issues) of this repository and believe that this is not a duplicate.
### Reproduction link
[](https://codesandbox.io/s/frosty-jones-hs63f2?file=/src/observer-computed.js)
### 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
);
});
/**
* 当前函数无任何相应式
*/
observe(computedData, (change) => {
console.log("observe fnc change:", change);
console.log("observe computedData.value:", computedData.value);
});
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
---
Contributor guide
Research direction
Run the linked CodeSandbox reproduction in /src/observer-computed.js using @formily/reactive@2.2.29, focusing on observe, observable, and observable.computed. Trace the observe and computed entry points to determine why changes to the computed value are not reported; done means the observer reacts to each resultKey update as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100