Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 296fb3e

Browse files
refactor: 追加effectStack的注释
1 parent ff37ce8 commit 296fb3e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎src/effect.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const effectStack: ReactiveEffect[] = []
5050
export function effect(fn: () => any, options: ReactiveEffectOptions = {}) {
5151
const effect = createReactiveEffect(fn, options)
5252
if (!options.lazy) {
53+
// 如果没有 lazy 选择就立即运行 effect()一次
5354
effect()
5455
}
5556
return effect
@@ -93,7 +94,7 @@ function run(effect: ReactiveEffect, fn: Function, args: unknown[]): unknown {
9394
* @param key 被依赖收集的对象key
9495
*/
9596
export function track(target: object, key: string | symbol) {
96-
// 获取最新入栈的 effect
97+
// 获取最新入栈的 effect(如果没有设置effect, effectStack即为空)
9798
const effect = effectStack[effectStack.length - 1]
9899
if (effect) {
99100
let depsMap = targetMap.get(target)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /