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

fix(runtime-core): trigger watcher with undefined as initial value #687

Merged
merged 1 commit into from
Feb 4, 2020

Conversation

posva
Copy link
Member

@posva posva commented Feb 3, 2020

Fix #683

@@ -61,6 +61,9 @@ export type StopHandle = () => void

const invoke = (fn: Function) => fn()

// initial value for watchers to trigger on undefined initial values
const INITIAL_WATCHER_VALUE = {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use a Symbol but it shouldn't change anything since this variable is never exposed to user code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, since objects are unique your way is good too. But symbols can help e.g. in debug of Vue itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But symbols can help e.g. in debug of Vue itself.

What case are you thinking of?

Symbols are also not supported by all platforms (even though we are using them in quite a few places already). To me, using an object works everywhere while being as simple as using Symbols and I couldn't think of a case where it would fail

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, object wins!

@yyx990803 yyx990803 merged commit 5742a0b into vuejs:master Feb 4, 2020
yangmingshan added a commit to vue-mini/vue-mini that referenced this pull request Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

watch handler not executed immediately if source returns undefined
4 participants