Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hojas committed May 30, 2024
1 parent 91bc04d commit ed61880
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"@antfu/eslint-config": "^2.19.1",
"@types/node": "^20.12.12",
"@types/node": "^20.12.13",
"eslint": "^9.3.0",
"typescript": "^5.4.5",
"vitepress": "^1.2.2"
Expand Down
52 changes: 26 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/docs/vue/effect.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: effect 源码分析
title: effect.ts 源码分析
---

# effect 源码分析
# effect.ts 源码分析

## effect.ts 源码分析

Expand Down
18 changes: 10 additions & 8 deletions src/docs/vue/reactive-effect.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: ReactiveEffect.ts 源码分析
title: reactiveEffect.ts 源码分析
---

# ReactiveEffect.ts 源码分析
# reactiveEffect.ts 源码分析

## track 函数

Expand Down Expand Up @@ -52,13 +52,13 @@ export const MAP_KEY_ITERATE_KEY = Symbol(__DEV__ ? 'Map key iterate' : '')
export function track(target: object, type: TrackOpTypes, key: unknown) {
if (shouldTrack && activeEffect) {
let depsMap = targetMap.get(target)
if (!depsMap)
if (!depsMap) {
targetMap.set(target, (depsMap = new Map()))

}
let dep = depsMap.get(key)
if (!dep)
if (!dep) {
depsMap.set(key, (dep = createDep(() => depsMap!.delete(key))))

}
trackEffect(
activeEffect,
dep,
Expand Down Expand Up @@ -110,8 +110,9 @@ export function trigger(
}
else {
// schedule runs for SET | ADD | DELETE
if (key !== void 0)
if (key !== void 0) {
deps.push(depsMap.get(key))
}

// also run for iteration key on ADD | DELETE | Map.SET
switch (type) {
Expand Down Expand Up @@ -169,6 +170,7 @@ export function trigger(
* @param key
*/
export function getDepFromReactive(object: any, key: string | number | symbol) {
return targetMap.get(object)?.get(key)
const depsMap = targetMap.get(object)
return depsMap && depsMap.get(key)
}
```

0 comments on commit ed61880

Please sign in to comment.