Skip to content

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

Closed

Conversation

josephperrott
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] angular.io application / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Currently, it is not possible to determine if a component is running in a BrowserAnimationsModule or NoopAnimationsModule 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?

[ ] Yes
[x] No

Other information

@josephperrott josephperrott force-pushed the animations-module-marker branch 2 times, most recently from 562f106 to ff7574e Compare March 30, 2018 00:58
@matsko matsko added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: major This PR is targeted for the next major release labels Apr 4, 2018
Copy link
Contributor

@matsko matsko left a 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 {
Copy link
Contributor

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');
Copy link
Contributor

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},
Copy link
Contributor

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[] = [
Copy link
Contributor

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 */ ) {}
} 

@@ -1,3 +1,12 @@
/** @experimental */
export declare const ANIMATION_MODULE_TYPE: InjectionToken<AnimationModuleType>;
Copy link
Contributor

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.

@IgorMinar IgorMinar added this to the v6.0 milestone Apr 9, 2018
@josephperrott josephperrott force-pushed the animations-module-marker branch 3 times, most recently from 8e3809b to bfa7ad2 Compare April 9, 2018 22:51
@mary-poppins
Copy link

You can preview 8e3809b at https://pr23075-8e3809b.ngbuilds.io/.

@josephperrott josephperrott force-pushed the animations-module-marker branch from bfa7ad2 to 32bca7b Compare April 9, 2018 23:01
@angular angular deleted a comment from mary-poppins Apr 9, 2018
@mary-poppins
Copy link

You can preview 32bca7b at https://pr23075-32bca7b.ngbuilds.io/.

@josephperrott josephperrott force-pushed the animations-module-marker branch from 32bca7b to 865213a Compare April 10, 2018 00:51
@mary-poppins
Copy link

You can preview 865213a at https://pr23075-865213a.ngbuilds.io/.

@IgorMinar IgorMinar added the action: merge The PR is ready for merge by the caretaker label Apr 12, 2018
@IgorMinar IgorMinar removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 12, 2018
@IgorMinar IgorMinar closed this in b551f84 Apr 13, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
@josephperrott josephperrott deleted the animations-module-marker branch October 2, 2019 16:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: animations cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants