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

feat(lib): lazy url config #78

Merged
merged 5 commits into from
Oct 13, 2024
Merged

feat(lib): lazy url config #78

merged 5 commits into from
Oct 13, 2024

Conversation

ChristopherPHolder
Copy link
Contributor

@ChristopherPHolder ChristopherPHolder commented Oct 9, 2024

Description

Allow the user to have a lazy configuration for the svg by allowing the url option to return an observable and reacting to the change.

provideFastSVG({
      url: (name: string) => timer(10000).pipe(map(() => `assets/svg-icons/${name}.svg`)),
}),

These changes do not seem to break the open-closed principle and do not cause breaking changes.

However, this does mean typing for the options a little less strict. As SvgLoadStrategy.load now takes a string | Observable and this is not inferred.

Additionally, this is only really possible because of the new function runInInjectionContext because a real user will most likely use a service and not a simple function that returns an observable.

Closes: #77

Notes
This is a draft, still need to cleanup code

Copy link
Contributor

@eneajaho eneajaho left a comment

Choose a reason for hiding this comment

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

It looks good to me!

@ChristopherPHolder ChristopherPHolder merged commit c92af22 into main Oct 13, 2024
1 check passed
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.

Allow lazy configuration of svgs through the url function
2 participants