(obj: T)
| 233 | * Make obj reactivity |
| 234 | */ |
| 235 | export function reactive<T extends object>(obj: T): UnwrapRef<T> { |
| 236 | if (!isObject(obj)) { |
| 237 | if (__DEV__) { |
| 238 | warn('"reactive()" must be called on an object.') |
| 239 | } |
| 240 | return obj |
| 241 | } |
| 242 | |
| 243 | if ( |
| 244 | !(isPlainObject(obj) || isArray(obj)) || |
| 245 | isRaw(obj) || |
| 246 | !Object.isExtensible(obj) |
| 247 | ) { |
| 248 | return obj as any |
| 249 | } |
| 250 | |
| 251 | const observed = observe(obj) |
| 252 | setupAccessControl(observed) |
| 253 | return observed as UnwrapRef<T> |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Make sure obj can't be a reactive |
searching dependent graphs…