angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.39k stars 6.76k forks source link

feat(MatIconRegistry): reactive signatures #29437

Open aalbericio opened 4 months ago

aalbericio commented 4 months ago

Feature Description

When I use MatIconRegistry, and I add an "iconSet" using "addSvgIconSet", I don't see any way of subscribing to what's internally doing: loading file -> generating an html/svg representation -> etc

And I don't know when all that computation has finished.

I'm using a little "hack" to subscribe to that workflow using:

matIconRegistry.getNamedSvgIcon(<name of icon I know it's in the iconSet>).subscribe(...)`

But that's kinda weak since I have to know the contents (what SVGs are included) in the iconSet.

I would like to have a robust API so that I can subscribe to that internal workflow and know when it has finished its calculations, something like:

matIconRegistry.addSvgIconSet(<icon_set_file>).subscribe(...)

Even more interesting, allow this registry to load multiple files at once:

matIconRegistry.addSvgIconSet([<icon_set_file_1>, <icon_set_file_2>...]).subscribe(...)

Use Case

Synchronize APP Icons configuration at bootstrap.

Thanks

crisbeto commented 4 months ago

There aren't really any calculations going on. The icon just makes an HTTP request when trying to display an icon, it extracts the SVG text and it caches the result. Even if we added events, I suspect they wouldn't be particularly useful.