| 74 | } |
| 75 | |
| 76 | export function createRef<T>( |
| 77 | options: RefOption<T>, |
| 78 | isReadonly = false, |
| 79 | isComputed = false |
| 80 | ): RefImpl<T> { |
| 81 | const r = new RefImpl<T>(options) |
| 82 | |
| 83 | // add effect to differentiate refs from computed |
| 84 | if (isComputed) (r as ComputedRef<T>).effect = true |
| 85 | |
| 86 | // seal the ref, this could prevent ref from being observed |
| 87 | // It's safe to seal the ref, since we really shouldn't extend it. |
| 88 | // related issues: #79 |
| 89 | const sealed = Object.seal(r) |
| 90 | |
| 91 | if (isReadonly) readonlySet.set(sealed, true) |
| 92 | |
| 93 | return sealed |
| 94 | } |
| 95 | |
| 96 | export function ref<T extends object>( |
| 97 | raw: T |