MCPcopy
hub / github.com/vuejs/core / removeSub

Function removeSub

packages/reactivity/src/effect.ts:432–470  ·  view source on GitHub ↗
(link: Link, soft = false)

Source from the content-addressed store, hash-verified

430}
431
432function removeSub(link: Link, soft = false) {
433 const { dep, prevSub, nextSub } = link
434 if (prevSub) {
435 prevSub.nextSub = nextSub
436 link.prevSub = undefined
437 }
438 if (nextSub) {
439 nextSub.prevSub = prevSub
440 link.nextSub = undefined
441 }
442 if (__DEV__ && dep.subsHead === link) {
443 // was previous head, point new head to next
444 dep.subsHead = nextSub
445 }
446
447 if (dep.subs === link) {
448 // was previous tail, point new tail to prev
449 dep.subs = prevSub
450
451 if (!prevSub && dep.computed) {
452 // if computed, unsubscribe it from all its deps so this computed and its
453 // value can be GCed
454 dep.computed.flags &= ~EffectFlags.TRACKING
455 for (let l = dep.computed.deps; l; l = l.nextDep) {
456 // here we are only "soft" unsubscribing because the computed still keeps
457 // referencing the deps and the dep should not decrease its sub count
458 removeSub(l, true)
459 }
460 }
461 }
462
463 if (!soft && !--dep.sc && dep.map) {
464 // #11979
465 // property dep no longer has effect subscribers, delete it
466 // this mostly is for the case where an object is kept in memory but only a
467 // subset of its properties is tracked at one time
468 dep.map.delete(dep.key)
469 }
470}
471
472function removeDep(link: Link) {
473 const { prevDep, nextDep } = link

Callers 2

stopMethod · 0.85
cleanupDepsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected