ngneat / svg-icon

šŸ‘» A lightweight library that makes it easier to use SVG icons in your Angular Application
https://netbasal.com
MIT License
257 stars 35 forks source link

fix: šŸ› icons multi provider #51

Closed kirills98 closed 3 years ago

kirills98 commented 3 years ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

If has two modules (A and B) that use SvgIconsModule.forChild() and this modules imports to module C then will be provided only icons from last imported module (for example B) and icons from other modules ( for example A) will be ignored.

Issue Number: N/A

What is the new behavior?

Now icons provider with multi: true parameter. It's mean that all provided icons will accessible as array by same token.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

NetanelBasal commented 3 years ago

I'm not sure what you're trying to solve. Please add specs.

kirills98 commented 3 years ago

I'm not sure what you're trying to solve. Please add specs.

I make small demo for this case.

My real case: i have several reusable components that uses inside SvgIconsModule.forChild(). If this components used together, then icon registering incorectly.

NetanelBasal commented 3 years ago

forChild is meant to be used only in lazy load modules.

In your example, they are eager. Do you want to use it in eager modules just to make it more organized?

kirills98 commented 3 years ago

@NetanelBasal yes. Because one of case using icons in external angular package (bundled by ng-packagr).
Of course we can make some our module for this or we can register icons manually. But i think it will good "out of box" :)

NetanelBasal commented 3 years ago

Please update the docs

kirills98 commented 3 years ago

@NetanelBasal i'm fixed docs, additionaly add @Self decorator for injecting icons in module, for improve re-register icons, provided in parent modules