当相关的单向 CP 更新时,计算属性不会重新计算
Computed properties are not re-calculating when dependent oneWay CP updates
假设我有一个 oneWay
CP,它最初绑定到一个模型 属性(因此如果更新可以自由发散)
CP 可以设置为值 fixed
和 dynamic
。我有一些 equal
CP,它们又依赖于这个 oneWayCp
改变
oneWayCp: oneWay('model.field')
isFixed: equal('oneWayCp', 'fixed').volatile().readOnly(),
isDynamic: equal('oneWayCp', 'dynamic').volatile().readOnly(),
我看到一个奇怪的错误,其中 isFixed
和 isDynamic
在 oneWayCp
更新时不更新
这是预期的行为吗?
其实你的问题是.volatile()
。基本上这会禁用 更新依赖键 行为。
Here是一个固定的旋转。
所以你应该这样做:
oneWayCp: oneWay('model.field')
isFixed: equal('oneWayCp', 'fixed').readOnly(),
isDynamic: equal('oneWayCp', 'dynamic').readOnly(),
It also does not automatically fire any change events. You must manually notify any changes if you want to observe this property.
假设我有一个 oneWay
CP,它最初绑定到一个模型 属性(因此如果更新可以自由发散)
CP 可以设置为值 fixed
和 dynamic
。我有一些 equal
CP,它们又依赖于这个 oneWayCp
改变
oneWayCp: oneWay('model.field')
isFixed: equal('oneWayCp', 'fixed').volatile().readOnly(),
isDynamic: equal('oneWayCp', 'dynamic').volatile().readOnly(),
我看到一个奇怪的错误,其中 isFixed
和 isDynamic
在 oneWayCp
更新时不更新
这是预期的行为吗?
其实你的问题是.volatile()
。基本上这会禁用 更新依赖键 行为。
Here是一个固定的旋转。
所以你应该这样做:
oneWayCp: oneWay('model.field')
isFixed: equal('oneWayCp', 'fixed').readOnly(),
isDynamic: equal('oneWayCp', 'dynamic').readOnly(),
It also does not automatically fire any change events. You must manually notify any changes if you want to observe this property.