Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(effectScope): allow multiple on() calls by tracking call count #12641

Open
wants to merge 1 commit into
base: vapor
Choose a base branch
from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Jan 3, 2025

The following code does not work correctly in the current vapor branch. When the button is clicked, the button text does not update.

<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>

<template>
  <button id="btn" @click="count++">{{ count }}</button>
  <div v-if="count < 1">{{ count }}</div>
  <div v-else>{{ count * 2 }}</div>
</template>

The issue is because scope.on is called twice:

if scope equals i.scope the following happens

scope1.on()  // activeEffectScope = scope1, prevScope = undefined
scope1.on()  // activeEffectScope = scope1, prevScope = scope1 (❌)
scope1.off() // activeEffectScope = scope1 (❌)
scope1.off() // activeEffectScope = undefined

The core also has a similar issue, see #12631. It is also caused by scope.on() being called multiple times. I have already created a PR #12632 to fix it. The changes in #12632 aim to avoid redundant updates to currentInstance, while this PR supports multiple calls to on. If this PR is merged, #12632 will no longer be needed.

@edison1105 edison1105 added the scope: vapor related to vapor mode label Jan 3, 2025
@edison1105 edison1105 changed the title feat(effectScope): allow multiple calls by tracking call count feat(effectScope): allow multiple on() calls by tracking call count Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: vapor related to vapor mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant