Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having to manually reset loaderState #6

Open
3 tasks done
Knyntsje opened this issue Nov 15, 2024 · 5 comments
Open
3 tasks done

Having to manually reset loaderState #6

Knyntsje opened this issue Nov 15, 2024 · 5 comments

Comments

@Knyntsje
Copy link

Describe the bug

When you have multiple pages that each have an InfiniteLoader in them, you have to manually reset the loaderState to ensure the infinite loader will work after navigation, as the page you were on could've called loaderState.complete.

For now I've worked around this by calling loaderState.reset in the onNavigate lifecycle.

I've made a reproduction in svelte playground, due to routing not being available in the playground, I've simulated the behaviour by having two components that will conditionally mount/unmount.

As a potential fix, resetting could be implemented in the onDestroy of InfiniteLoader.svelte, or perhaps a loaderState should be created by the user and passed to the InfiniteLoader, so that not the same loaderState is being used. Which could also introduce being able to use multiple infinite loaders on the same page.

Reproduction

https://svelte.dev/playground/eac5ad4404344f31912b9073c76b5a21

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 7800X3D 8-Core Processor
    Memory: 19.71 GB / 31.75 GB

Used Package Manager

npm

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@shumadrid
Copy link

Hi, did u find some other package for Svelte for infinite loading? Having this problem too, can't really use multiple instances with this package.

@ndom91
Copy link
Owner

ndom91 commented Mar 10, 2025

Hey sorry missed this until now.

I think resetting it onDestroy makes sense and doesn't require any additional work on the users part.

I'll add this this week 🙏

@shumadrid
Copy link

Hi, do you have any plans to implement the option where eachInfiniteLoader has it's own loaderState? This would allow you to have multiple lists at once. How hard would implementing that be?

@Knyntsje
Copy link
Author

Hey sorry missed this until now.

I think resetting it onDestroy makes sense and doesn't require any additional work on the users part.

I'll add this this week 🙏

Great to hear! And like @shumadrid mentioned it would be cool if you could consider adding the ability to optionally have a separate loaderState for each InfiniteLoader to support multiple instances.

@shumadrid
Copy link

Especially since the only other infinite loading package is svelte-infinite-loading, and that one isn't for Svelte 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants