ngx-timeago
ngx-timeago copied to clipboard
Add ngZone.runOutsideAngular
Add an ngZone exclusion to prevent the macro task running in the background. Need this update to help Protractor (e2e test) not hang indefinitely.
would be really nice to have it merged
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));
}
}
@hoancmg can you fix the tests and use angular commit message guidelines? I will merge it afterwards.
This is a great library, but unusable for me (and I'm sure many others) until it is compatible with protractor testing.