Skip to content
New issue

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

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

Already on GitHub? # to your account

Lazy load icons #2

Closed
joeldrapper opened this issue Aug 31, 2024 · 1 comment · Fixed by #6
Closed

Lazy load icons #2

joeldrapper opened this issue Aug 31, 2024 · 1 comment · Fixed by #6
Assignees

Comments

@joeldrapper
Copy link

At the moment, all the icons are being parsed and loaded into memory when you require the gem, whether you use them or not. I think it would make sense to use Ruby’s autoloading feature instead.

You would use this instead of require and require_relative. Take a look at how we do this in Phlex itself. At the top of each module, we specify sub modules and where to find their implementation. When Ruby detects that one of those sub modules is required, it will load it.

https://github.com/phlex-ruby/phlex/blob/de2e0fbc0f4e3637a50bfa53539b6eba75a1767d/lib/phlex.rb#L7-L24

Alternatively, the Zeitwerk gem allows you to autoload files just by putting them in the right place and naming them consistently. That might end up being a great option for this project. We use the autoload feature directly in Phlex just to avoid an extra dependency and keep things simple.

https://github.com/fxn/zeitwerk

@AliOsm AliOsm mentioned this issue Sep 1, 2024
@AliOsm AliOsm self-assigned this Sep 1, 2024
@AliOsm
Copy link
Owner

AliOsm commented Sep 1, 2024

@joeldrapper Could you please take a look at #6? Can I add you as a reviewer if you are not a collaborator 🤔

@AliOsm AliOsm closed this as completed in #6 Sep 2, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants