Skip to content

Commit

Permalink
refactor(animations): EnvironmentProviders for `provideAnimationsAs…
Browse files Browse the repository at this point in the history
…ync` (#52862)

This will prevent devs from using these providers in at a component level.

PR Close #52862
  • Loading branch information
JeanMeche authored and thePunderWoman committed Nov 13, 2023
1 parent 5ee11a7 commit 9135dba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions goldens/public-api/platform-browser/animations/async/index.md
Expand Up @@ -4,10 +4,10 @@
```ts

import { Provider } from '@angular/core';
import { EnvironmentProviders } from '@angular/core';

// @public
export function provideAnimationsAsync(type?: 'animations' | 'noop'): Provider[];
export function provideAnimationsAsync(type?: 'animations' | 'noop'): EnvironmentProviders;

// (No @packageDocumentation comment for this package)

Expand Down
9 changes: 5 additions & 4 deletions packages/platform-browser/animations/async/src/providers.ts
Expand Up @@ -7,7 +7,7 @@
*/

import {DOCUMENT} from '@angular/common';
import {ANIMATION_MODULE_TYPE, NgZone, Provider, RendererFactory2} from '@angular/core';
import {ANIMATION_MODULE_TYPE, EnvironmentProviders, makeEnvironmentProviders, NgZone, RendererFactory2} from '@angular/core';
import {ɵDomRendererFactory2 as DomRendererFactory2} from '@angular/platform-browser';

import {AsyncAnimationRendererFactory} from './async_animation_renderer';
Expand Down Expand Up @@ -40,8 +40,9 @@ import {AsyncAnimationRendererFactory} from './async_animation_renderer';
* @publicApi
* @developerPreview
*/
export function provideAnimationsAsync(type: 'animations'|'noop' = 'animations'): Provider[] {
return [
export function provideAnimationsAsync(type: 'animations'|'noop' = 'animations'):
EnvironmentProviders {
return makeEnvironmentProviders([
{
provide: RendererFactory2,
useFactory: (doc: Document, renderer: DomRendererFactory2, zone: NgZone) => {
Expand All @@ -53,5 +54,5 @@ export function provideAnimationsAsync(type: 'animations'|'noop' = 'animations')
provide: ANIMATION_MODULE_TYPE,
useValue: type === 'noop' ? 'NoopAnimations' : 'BrowserAnimations',
},
];
]);
}

0 comments on commit 9135dba

Please sign in to comment.