reactive.spec.ts — vue Source File
Architecture documentation for reactive.spec.ts, a typescript file in the vue codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 214b4202_bac7_a48c_7d98_678c51016258["reactive.spec.ts"] d970b406_3424_b00e_55dd_82e98ab5aac2["v3"] 214b4202_bac7_a48c_7d98_678c51016258 --> d970b406_3424_b00e_55dd_82e98ab5aac2 eb7174f6_f021_7b84_3862_bd9a0db1b30a["observer"] 214b4202_bac7_a48c_7d98_678c51016258 --> eb7174f6_f021_7b84_3862_bd9a0db1b30a 1a5e86bd_1a43_1523_b480_a1b1a98c87ad["effect"] 214b4202_bac7_a48c_7d98_678c51016258 --> 1a5e86bd_1a43_1523_b480_a1b1a98c87ad style 214b4202_bac7_a48c_7d98_678c51016258 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { ref, isRef, reactive, isReactive, toRaw, markRaw, computed } from 'v3'
import { set } from 'core/observer'
import { effect } from 'v3/reactivity/effect'
describe('reactivity/reactive', () => {
test('Object', () => {
const original = { foo: 1 }
const observed = reactive(original)
// @discrepancy Vue 2 does not create proxy objects
// expect(observed).not.toBe(original)
expect(isReactive(observed)).toBe(true)
// @discrepancy Vue 2 does not create proxy objects
// expect(isReactive(original)).toBe(false)
// get
expect(observed.foo).toBe(1)
// has
expect('foo' in observed).toBe(true)
// ownKeys
expect(Object.keys(observed)).toEqual(['foo'])
})
test('proto', () => {
const obj = {}
const reactiveObj = reactive(obj)
expect(isReactive(reactiveObj)).toBe(true)
// read prop of reactiveObject will cause reactiveObj[prop] to be reactive
// @ts-ignore
const prototype = reactiveObj['__proto__']
const otherObj = { data: ['a'] }
expect(isReactive(otherObj)).toBe(false)
const reactiveOther = reactive(otherObj)
expect(isReactive(reactiveOther)).toBe(true)
expect(reactiveOther.data[0]).toBe('a')
})
test('nested reactives', () => {
const original = {
nested: {
foo: 1
},
array: [{ bar: 2 }]
}
const observed = reactive(original)
expect(isReactive(observed.nested)).toBe(true)
expect(isReactive(observed.array)).toBe(true)
expect(isReactive(observed.array[0])).toBe(true)
})
// @discrepancy Vue 2 does not support collections
// test('observing subtypes of IterableCollections(Map, Set)', () => {
// // subtypes of Map
// class CustomMap extends Map {}
// const cmap = reactive(new CustomMap())
// expect(cmap instanceof Map).toBe(true)
// expect(isReactive(cmap)).toBe(true)
// cmap.set('key', {})
// expect(isReactive(cmap.get('key'))).toBe(true)
// ... (253 more lines)
Dependencies
- effect
- observer
- v3
Source
Frequently Asked Questions
What does reactive.spec.ts do?
reactive.spec.ts is a source file in the vue codebase, written in typescript.
What does reactive.spec.ts depend on?
reactive.spec.ts imports 3 module(s): effect, observer, v3.
Where is reactive.spec.ts in the architecture?
reactive.spec.ts is located at test/unit/features/v3/reactivity/reactive.spec.ts (directory: test/unit/features/v3/reactivity).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free