Git Product home page Git Product logo

Comments (6)

oumoussa98 avatar oumoussa98 commented on July 19, 2024 1

Thank you @tadvas.
I think what you missed here is resetting the comments array to get the desired behavior.
Add a watcher to testNumber and reset comments on each change or better reset the comments array
on the load function before fetching new data.

const load = async ($state) => {
  comments.value = [];
  // then fetch new data
};

from vue3-infinite-loading.

oumoussa98 avatar oumoussa98 commented on July 19, 2024 1

In my example above try to remove the identifier prop and you'll see that it doesn't work anymore
So identifier ensures that the infinite event will be triggered whenever the identifier changes and the infinite is visible in the viewport.
Because once $state.complete() is called the observer get's disconnected but once the identifier is changed the observer starts again and emits the event.

from vue3-infinite-loading.

oumoussa98 avatar oumoussa98 commented on July 19, 2024

identifier prop expects a reactive variable so you should declare testNumber as follows

let testNumber = ref(1);

And you should clear comments variable on each change
Here is an example on staskblitz
even though it calls $state.complete() the infinite event is emitted if the identifier changed

from vue3-infinite-loading.

tadvas avatar tadvas commented on July 19, 2024

@oumoussa98 thanks for the reply
Good catch regarding reactive variable.
But even in example, the component doesn't get reloaded...
Fix me, if I wrong, please

Sorry for bothering you, but it's the best infinity scroll for vue3, so I want to make it work :)

from vue3-infinite-loading.

tadvas avatar tadvas commented on July 19, 2024

And I mean by reloaded is sending a request to the server to grab new params. I don't see a request.
However, after checking the source code, I don't see an issue as well, so looks like I just need a help(

from vue3-infinite-loading.

tadvas avatar tadvas commented on July 19, 2024

I made it work.
Watcher with resetting of comments+page does the trick.
Working example
However, the question regarding the identifier remains :)

In my example, I don't see any effect of using it. Once the watcher is activated - the list is reset.
I guess the idea here is to avoid using watcher in the code. Should it be triggered in the library once the identifier prop is changed?

from vue3-infinite-loading.

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.