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

Refactor lazyload to avoid unnecessary object creation #1

Merged
merged 1 commit into from
Nov 3, 2020

Conversation

MacFJA
Copy link
Contributor

@MacFJA MacFJA commented Nov 1, 2020

The current implementation create multiple IntersectionObserverCallback and IntersectionObserver, which are not needed.

@swyxio
Copy link
Owner

swyxio commented Nov 1, 2020

i might be wrong, but i think action function bodies are only run once? @kevmodrome. only the update() gets run multiple times.

@MacFJA
Copy link
Contributor Author

MacFJA commented Nov 3, 2020

I made a small example: https://svelte.dev/repl/2903aeece4524f0a9a66db758503a887?version=3.29.4 (see the console)

The main body is call on every time the action is used.
The update function only if the value change after the initialisation

@MacFJA MacFJA force-pushed the refactor-lazyload branch from 9e252b4 to 060959e Compare November 3, 2020 20:34
@swyxio
Copy link
Owner

swyxio commented Nov 3, 2020

awesome, thank you very much!

@swyxio swyxio merged commit d95473e into swyxio:main Nov 3, 2020
@MacFJA MacFJA deleted the refactor-lazyload branch November 3, 2020 21:39
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

Successfully merging this pull request may close these issues.

2 participants