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

Multiple infinite-loading component on same page not working as expected in vue 3 #327

Open
santhanakrishnanstark opened this issue Oct 19, 2022 · 2 comments

Comments

@santhanakrishnanstark
Copy link

santhanakrishnanstark commented Oct 19, 2022

Version

3.0.0-alpha.0-0

Vue.js version

3.2

Reproduction Link

You can check the issue here - https://stackblitz.com/edit/vue-ckn2zu?file=src%2FApp.vue

Steps to reproduce

  1. load the stackblitz page and see the app once it runs. initially it will load the 1st component data, and you can see 2nd component loading icon. once the second component show 'no data available' then first component also affecting.

What is Expected?

Each infinite loading component should run separately with its own set of data.

What is actually happening?

if one component doesn't have the data then other component also showing 'no data available ' error.

@phlegx
Copy link

phlegx commented Jul 5, 2023

The problem is the eventHub in the code. This emits global events to all subscriber.

@phlegx
Copy link

phlegx commented Jul 5, 2023

E.g.

eventHub.$on('$InfiniteLoading:loaded', () => { ... }

should be:

eventHub.$on('$InfiniteLoading:loaded', (ev) => {
  if (!ev || ev.target !== this) return;
  ...
});

Same changes for:

eventHub.$on('$InfiniteLoading:complete', () => { ... }
eventHub.$on('$InfiniteLoading:reset', () => { ... }

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

2 participants