You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
andrequire_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
The text was updated successfully, but these errors were encountered: