Skip to content

Chained 'pre' watchers #1777

@skirtles-code

Description

@skirtles-code

Version

master at commit 11ed210

The example is using a build of the latest master branch as it relies on a commit that went in yesterday . I'm unclear whether there's a better way to report problems against the latest master.

Reproduction link

https://codesandbox.io/s/holy-sunset-fc8di?file=/index.html

Steps to reproduce

  1. Open the console log.
  2. Click the button.
  3. Note that the watcher for otherValue isn't called until after render, despite being flush: 'pre'.

What is expected?

Changes made by a 'pre' watcher should trigger other 'pre' watchers prior to any rendering.

In Vue 2 this kind of watcher chaining worked fine, see:

https://jsfiddle.net/skirtle/vnkxz35p/9/

What is actually happening?

The second 'pre' watcher isn't called until after render.


Why do you need a watcher that runs before render?

The example is for illustration only. I've explained in greater detail here why this is important in real applications.

Why not use flush: 'sync' on that second watcher?

In this simple example that would work.

But using 'sync' brings its own problems, such as those discussed in #1763. If the watcher were watching a computed property that also depended on props it wouldn't be viable to use 'sync'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions