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: singleton downloader #2190

Open
wants to merge 5 commits into
base: fix-ci
Choose a base branch
from

Conversation

arjitcodes
Copy link

fix: #2154
Implement a singleton pattern for the Downloader class.

@benoit74 benoit74 self-requested a review March 19, 2025 09:29
Copy link
Contributor

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but this is not what we want.

The goal of this issue about a singleton is to:

  • have a single object, initialized once and for all, so that all calls have the same settings throughout the codebase ; here you've made all settings public and writable which means that we continue to have various behaviors ; maybe one or two settings must be tweakable at Downloader invocation, but then it means it is not a property of the object but a property of the invocation (function argument)
  • stop passing downloader object in function invocation ; here you continue to pass the object instead of simply using the singleton in the function code (and importing this singleton in file obviously)

@arjitcodes
Copy link
Author

I apologize for the misunderstanding. I got it now.

@arjitcodes arjitcodes marked this pull request as draft March 19, 2025 10:08
@arjitcodes arjitcodes force-pushed the refactor/downloader-singleton branch 2 times, most recently from 63e4df7 to c14e1f1 Compare March 22, 2025 04:53
@arjitcodes arjitcodes requested a review from benoit74 March 22, 2025 04:56
@arjitcodes arjitcodes marked this pull request as ready for review March 22, 2025 04:56
Copy link
Contributor

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general remarks:

  • please remove all commented code, this is not needed in the long run and makes the PR hard to read.
  • I'm very embarassed by the use of #foo private variable (in JS) ; while correct, it looks to me that most variable are declared with private foo (private TS variable) and having a mix of both semantic is kinda weird. And I'm really not sure we need the safety of JS private variables. Plus I find the use of a private JS variable + a public getter very verbose compared to simply having a public readonly foo. Your views on this are welcomed.

@arjitcodes arjitcodes requested a review from benoit74 March 25, 2025 15:09
@benoit74
Copy link
Contributor

@arjitcodes is this ready for a new review pass?

@arjitcodes
Copy link
Author

Yes

@benoit74 benoit74 force-pushed the refactor/downloader-singleton branch from f92a0be to cf7e4ee Compare March 28, 2025 14:16
@benoit74 benoit74 changed the base branch from main to fix-ci March 28, 2025 14:17
@benoit74
Copy link
Contributor

Rebased on what is supposed to be a fixed CI.

Copy link
Contributor

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests are failing while they are not supposed to, can you please have a look (might be a temporary glitch, but better to confirm locally before running CI again).

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.

Downloader(s) should be a singleton(s)
2 participants