Giter VIP home page Giter VIP logo

Comments (6)

LinusBorg avatar LinusBorg commented on May 3, 2024 1

Love it as well as the other part of this.

A nice side effect of this approach would be that it solves the problem of naming conflicts when we would introduce new lifecycle hooks in later versions, right?

Right now, in the public discussion about the class API, we are in a back and forth how to namespace lifecycle hooks when using the class API. If we declare lifecycle hooks deprecated, or committed to introducing new hooks as these dynamic lifecylce hooks only, risks of breaking our user's code in the future disappear.

from core.

yyx990803 avatar yyx990803 commented on May 3, 2024 1

I don't get why using value instead of state here.

Yes, the fetch example can use state instead.

For the mouse example, if you return a plain object, x and y becomes actual JavaScript values, and they will never update. Then you would have to bind the object like this instead:

data() {
  const mouse = useMousePosition()
  return {
    mouse
  }
}

Then access it as mouse.x and mouse.y. This works of course, but you'd have to do this even if the function only exposes a single value - which essentially is a ref.

Do the same rule for automatic watcher removal apply to hook listeners?

Lifecycle hooks don't need to be explicitly removed if the component is already unmounted (because they would never fire again)

from core.

Akryum avatar Akryum commented on May 3, 2024

I could totally see a babel plugin compiling res = to res.value = 😸

from core.

posva avatar posva commented on May 3, 2024

I don't get why using value instead of state here.
Do the same rule for automatic watcher removal apply to hook listeners?

Everything else looks good!

Regarding replacing lifecycle hooks in class declarations, I don't think we should replace them because it's a less intuitive api

from core.

yyx990803 avatar yyx990803 commented on May 3, 2024

Published: vuejs/rfcs#23

from core.

381510688 avatar 381510688 commented on May 3, 2024

in vue2

<Child @hook:mounted="doSomething"></Child>

parent components can listen to its children's’ lifecycle hooks. especially for third-party components.

What should we do in VUE3?

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.