-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(youtube-player): add config option to automatically load the YouTube API #21401
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
Conversation
|
||
@NgModule({ | ||
imports: [YouTubePlayerModule], | ||
// Optionally tells the `youtube-player` component to automatically load | ||
// the YouTube iframe API. Omit this if you plan to load the API yourself. | ||
providers: [{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jelbourn I would appreciate your feedback on a couple of things that I was considering when implementing it:
- How the config should be provided: through an injection token like here or through something like
YouTubePlayerModule.withConfig({ loadApi: true })
. I went with the former, because it's clearer what is going on, but I can see an argument for the latter, because the API is a bit cleaner and I expect that the most common use case would be to let the component load the API automatically. I wouldn't mind changing it to use the second approach. - Whether
loadApi
should be turned on by default. I decided against it, because it does add an external script to people's apps and I figured that's something we'd want them to opt into, but it does make it slightly harder to consume.
I'm still quite leery of adding an API that loads the API for you. My rationale is along the lines of:
I'll also comment this on the issue |
I think that your points are valid, but here's why I decided to do it:
Regarding your points:
I was planning to do something similar for the Google Maps API, if we managed to agree how this one would be handled, since it's set up in the exact same way.
I think that's fair for something like Angular or jQuery where there are different versions and ways to load the code. In the YouTube case, this is the only way of doing it since our component is tightly coupled to the
As I mentioned above, in this particular case there is only one way of loading the API. The only decision is between loading it up-front or doing so lazily and I'd argue that doing it lazily is preferable.
As far as I'm aware, there is only one possible version. There's a risk of including the |
e3d867f
to
ff91efb
Compare
ff91efb
to
613cbfd
Compare
613cbfd
to
f63a644
Compare
…Tube API Adds a new injection token that allows the `YouTubePlayer` to automatically load the API, instead of depending on it to be loaded by the consumer. Fixes angular#17037.
f63a644
to
e31d3c7
Compare
Closing in favor of #28171. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds a new injection token that allows the
YouTubePlayer
to automatically load the API, instead of depending on it to be loaded by the consumer.Fixes #17037.