IssueRaiser

asynchronous providers

<!-- PLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION. ISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION. --> ## I'm submitting a... <!-- Check one of the following options with "x" --> <pre><code> [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report <!-- Please search GitHub for a similar issue or PR before submitting --> [ X] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question </code></pre> ## Current behavior <!-- Describe how the issue manifests. --> Angular doesn't seem to support providers which asynchronously create their object / service. For those who want to load config from a server dynamically, they seem to be encouraged to use a kludge comprised of creating a `ConfigService` and then using `APP_INITIALIZER` to delay the bootstrapping just long enough to make an async call and inject the results into the `ConfigService`. But, this is a hack, and is buggy with race conditions - the `ConfigService` may potentially be injected into other services, and be used / read from before this bootstrapping happens, causing bugs because the object gets used before it's ready. Here's a plunk which demonstrates the problem: https://plnkr.co/edit/plWAT5i5BFtjastSdaVy?p=preview Notice the problem is that another service will read

Posted by rehfeldchris on Apr 10, 2018, 1:38 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

support (Sysadmin)

asynchronous providers

rehfeldchrisApr 10, 2018, 1:38 AM

<!-- PLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION. ISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION. --> ## I'm submitting a... <!-- Check one of the following options with "x" --> <pre><code> [ ] Regression (a behavior that used to work and stopped working in a new release) [ ] Bug report <!-- Please search GitHub for a similar issue or PR before submitting --> [ X] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question </code></pre> ## Current behavior <!-- Describe how the issue manifests. --> Angular doesn't seem to support providers which asynchronously create their object / service. For those who want to load config from a server dynamically, they seem to be encouraged to use a kludge comprised of creating a `ConfigService` and then using `APP_INITIALIZER` to delay the bootstrapping just long enough to make an async call and inject the results into the `ConfigService`. But, this is a hack, and is buggy with race conditions - the `ConfigService` may potentially be injected into other services, and be used / read from before this bootstrapping happens, causing bugs because the object gets used before it's ready. Here's a plunk which demonstrates the problem: https://plnkr.co/edit/plWAT5i5BFtjastSdaVy?p=preview Notice the problem is that another service will read

Comments (0)

No comments yet. Start the discussion.

Comment on this issue