maoberlehner / vue-lazy-hydration

Lazy Hydration of Server-Side Rendered Vue.js Components
MIT License
1.19k stars 52 forks source link

`this.$refs.hydrate.hydrated` not possible in version 2? #78

Open simplenotezy opened 3 years ago

simplenotezy commented 3 years ago

In version one you could do:

<LazyHydrate ref="hydrate" when-visible>

And then in your javascript method do like so:

if (this.$refs.hydrate.hydrated) {

However, in version 2 that seems not to be possible anymore.

Am I missing something? I didn't find a changelog from version 1 -> 2 so not sure what has changed.

maoberlehner commented 3 years ago

Because I've completely rewritten v2, this is not possible anymore. I did not consider this a breaking change because your approach relies on implementation details that were not meant to be public and were not in the documentation. I could add it back in. However, I'd prefer not to, to keep the code as simple as possible.

I also don't recommend doing this. The Vue model is props down, events up.

Would it be useful to you if <LazyHydrate> emits an event at the moment of hydration?

<LazyHydrate @hydrate="isHydrated = true">
simplenotezy commented 3 years ago

Yes, that would be very helpful @maoberlehner

mattickx commented 3 years ago

This certainly broke certain things in production. The events suggestion would certainly fix this. I'll keep an older version running for now. +1

mastercoding commented 3 years ago

I might be missing something, but this is an essential feature for lazy loading components to work for example (and to not have all of them "preloaded" on page load). And event would work fine, though.