Comments (6)
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.
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.
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.
@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.
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.
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)
- Broken github url in demo page
- How to trigger by ref's dom node $state.complete() HOT 5
- Data not consistently being loaded to the end during scroll (using demo code from docs in Nuxt3 app) HOT 2
- Expose function to reset the state HOT 2
- Error when component already has explicitly named default slot HOT 1
- the loader doesn't load nicely only half of the circle can be seen. HOT 1
- Compiler error when running demo project from dev branch
- Add spinning wheel slot option HOT 2
- Identifier doesn't trigger reload upon data change HOT 2
- [HELP] Does it support typescript import? HOT 2
- Issues with inverted/top infinite load. HOT 10
- Reset to the top when scrolling with infinite loading HOT 1
- export 'default' (imported as 'InfiniteLoading') was not found in 'v3-infinite-loading' (module has no exports) HOT 7
- Cannot read properties of null (reading 'getBoundingClientRect') HOT 3
- Identifier change triggers reload twice HOT 1
- Slot for name="complete" doesn't work HOT 4
- Potential for duplicate observers activation HOT 1
- Issues with top scroll HOT 1
- Manually trigger infinite HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue3-infinite-loading.