Skip to content
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

Add ngZone.runOutsideAngular #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

hoancmg
Copy link

@hoancmg hoancmg commented Apr 15, 2020

Add an ngZone exclusion to prevent the macro task running in the background.
Need this update to help Protractor (e2e test) not hang indefinitely.

@mpashkovskiy
Copy link

would be really nice to have it merged

@mpashkovskiy
Copy link

While the PR is open, limited/dirty workaround would be to implement wrapper like that:

import { ChangeDetectorRef, NgZone, Pipe, PipeTransform } from '@angular/core';
import { TimeagoDefaultClock, TimeagoDefaultFormatter, TimeagoIntl, TimeagoPipe } from 'ngx-timeago';

@Pipe({
  name: 'timeagoWrapper',
})
export class TimeagoWrapperPipe implements PipeTransform {

  private timeago: TimeagoPipe;

  constructor(private cd: ChangeDetectorRef, private ngZone: NgZone) {
    this.timeago = new TimeagoPipe(
      new TimeagoIntl(),
      this.cd,
      new TimeagoDefaultFormatter(),
      new TimeagoDefaultClock()
    );
  }

  transform(value: any, ...args: any[]): any {
    return this.ngZone.runOutsideAngular(() => this.timeago.transform(value));
  }

}

@ihym
Copy link
Owner

ihym commented Jun 1, 2020

@hoancmg can you fix the tests and use angular commit message guidelines? I will merge it afterwards.

@conor-mac-aoidh
Copy link

This is a great library, but unusable for me (and I'm sure many others) until it is compatible with protractor testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants