-
Notifications
You must be signed in to change notification settings - Fork 26.4k
feat(platform-browser): add token marking which the type of animation… #23075
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(platform-browser): add token marking which the type of animation… #23075
Conversation
562f106
to
ff7574e
Compare
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.
Please fix the things I pointed out.
/** | ||
* @experimental Animation support is experimental. | ||
*/ | ||
export enum BrowserAnimationsModules { |
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.
Rename to AnimationModuleType
(because it doesn't rely 100% on browser and BrowserAnimationsModules
is too easy to confuse with BrowserAnimationsModule
).
* @experimental Animation support is experimental. | ||
*/ | ||
export const BROWSER_ANIMATIONS_MODULE = | ||
new InjectionToken<BrowserAnimationsModules>('BrowserAnimationsModule'); |
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.
Same here.
@@ -50,12 +64,16 @@ const SHARED_ANIMATION_PROVIDERS: Provider[] = [ | |||
*/ | |||
export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [ | |||
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver}, | |||
{provide: BROWSER_ANIMATIONS_MODULE, useValue: BrowserAnimationsModules.BrowserAnimations}, |
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.
ANIMATION_MODULE_TYPE
...SHARED_ANIMATION_PROVIDERS | ||
]; | ||
|
||
/** | ||
* Separate providers from the actual module so that we can do a local modification in Google3 to | ||
* include them in the BrowserTestingModule. | ||
*/ | ||
export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] = | ||
[{provide: AnimationDriver, useClass: NoopAnimationDriver}, ...SHARED_ANIMATION_PROVIDERS]; | ||
export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] = [ |
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.
Could we make a test inside of https://github.com/angular/angular/blob/master/packages/core/test/animation/animation_integration_spec.ts
This way if the token is removed then we'll know if something fails in the project.
// put this at the top of the file just under the top-level describe() call...
describe('animation modules', function() {
it('should hint at BrowserAnimationsModule being used', () => {
TestBed.configureTestingModule({
declarations: [ SharedAnimationCmp ],
imports: [BrowserAnimationsModule]
});
TestBed.configureTestingModule({declarations: [SharedAnimationCmp]});
const fixture = TestBed.createComponent(Cmp);
const cmp = fixture.componentInstance;
expect(cmp.tokenValue).toEqual(...);
});
it('should hint at NoopAnimationsModule being used', () => {
TestBed.configureTestingModule({
declarations: [ SharedAnimationCmp ],
imports: [NoopAnimationsModule]
});
TestBed.configureTestingModule({declarations: [SharedAnimationCmp]});
const fixture = TestBed.createComponent(Cmp);
const cmp = fixture.componentInstance;
expect(cmp.tokenValue).toEqual(...);
});
});
class SharedAnimationCmp {
public tokenVaue;
constructor( /* inject the token */ ) {}
}
c8cf07c
to
2634b97
Compare
@@ -1,3 +1,12 @@ | |||
/** @experimental */ | |||
export declare const ANIMATION_MODULE_TYPE: InjectionToken<AnimationModuleType>; |
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.
I discussed this with @matsko.
Let's change this to ANIMATION_MODULE_NAME: InjectionToken<"BrowserAnimationsModule"|"NoopAnimationsModule">
It's simpler and exposes less of a API surface.
8e3809b
to
bfa7ad2
Compare
You can preview 8e3809b at https://pr23075-8e3809b.ngbuilds.io/. |
bfa7ad2
to
32bca7b
Compare
You can preview 32bca7b at https://pr23075-32bca7b.ngbuilds.io/. |
… module nearest in the injector tree
32bca7b
to
865213a
Compare
You can preview 865213a at https://pr23075-865213a.ngbuilds.io/. |
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently, it is not possible to determine if a component is running in a
BrowserAnimationsModule
orNoopAnimationsModule
context at runtime.Issue Number: N/A
What is the new behavior?
An token is provided as a marker to be able to determine which animation context is being used for the component at runtime.
Does this PR introduce a breaking change?
Other information