feat(ref): 实现 ref 值变化检测和依赖触发功能
- 在 shared 包中新增 hasChanged 函数用于比较值是否发生变化 - 修改 RefImpl 类添加 _rawValue 属性存储原始值 - 实现 ref setter 中的值变化检测逻辑 - 添加 triggerRefValue 函数用于触发 ref 依赖更新 - 优化 ref 的 getter 和 setter 方法实现响应式更新
This commit is contained in:
@@ -3,3 +3,11 @@ export const isArray = Array.isArray
|
||||
|
||||
export const isObject = (val: unknown) =>
|
||||
val !== null && typeof val === 'object'
|
||||
|
||||
/**
|
||||
* 对比两个数据是否发生改变
|
||||
* @param value
|
||||
* @param oldValue
|
||||
*/
|
||||
export const hasChanged = (value: any, oldValue: any): boolean =>
|
||||
!Object.is(value, oldValue)
|
||||
|
||||
Reference in New Issue
Block a user