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

[Feature Request] Retry when loading failed #501

Open
conde2 opened this issue Apr 18, 2021 · 3 comments
Open

[Feature Request] Retry when loading failed #501

conde2 opened this issue Apr 18, 2021 · 3 comments

Comments

@conde2
Copy link

conde2 commented Apr 18, 2021

The problem I'm facing is that when the images failed to load for example network connection lost it will not load anymore, even if the network connection is enabled again.

Is there any way to add a retry or any suggestion how to fix that ?

Probably the same as:

#129

@tjoskar
Copy link
Owner

tjoskar commented Apr 25, 2021

Hi,
Is it possible for you to use a service worker? I guess it should be fairly easy to implement the functionality there?

Of would it be possible for you to use a custom hook?

import { IntersectionObserverHooks, Attributes } from 'ng-lazyload-image';
import { defer, retry } from 'rxjs';

class LazyLoadImageHooks extends IntersectionObserverHooks {
  loadImage(attributes: Attributes): ObservableInput<string> {
    return defer(() => this.super.loadImage(attributes)).pipe(retry(2));
  }
}

@conde2
Copy link
Author

conde2 commented Apr 25, 2021

Thanks, that worked!

@conde2 conde2 closed this as completed Apr 25, 2021
@conde2 conde2 reopened this Apr 25, 2021
@conde2
Copy link
Author

conde2 commented Apr 25, 2021

How can I cancel the retry if the element in the screen is not visible anymore?

image

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