Skip to content

Component updating without computed property dep changing #1811

Closed
@paulshen

Description

@paulshen

What problem does this feature solve?

I'm relatively new to Vue. Learning about computed properties (cool feature!), I expected a component that has a computed dependency to only update when the computed value "changes" (wrt hasChanged) instead of updating whenever the recursive deps change.

Here is a CodeSandbox example https://codesandbox.io/s/floral-pine-nvk0f?file=/src/App.vue
The watch does its own hasChanged check and updates only when the computedCount changes (10x less than count). I expect the component to update at the same rate.

A practical use case is ability to run a quicker timer update (say every 100ms) with the UI only rendering seconds (every 1s). Another example is only rendering only user.name but the underlying user has irrelevant changes.

You can create a separate component to add the change checking but it seems it could work in same component. I couldn't find a relevant issue. I can see the complexity tradeoff (needs external state when tracking read dependencies) but was wondering if that was the case.

What does the proposed API look like?

Same API but different component update behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions