Best way to wait for 3rd-party JS library to finish initializing within Angular 2 service?
问题 I'm wrapping a 3rd-party JS library in an Angular service. How can I guarantee that the 3rd-party JS library is loaded/initialized/etc. before using my service? Can you take a look at the following code and tell me if this is a good coding practice ? I'm setting up a promise in the service's constructor (promise that will eventually be fulfilled) and I have the service methods depend on the success of that promise (see getMessages ). @Injectable() export class GmailService { private