Edit: I am looking to enhance the functionality of ngx-translate's pipe by extending it. Here is an example of how I achieved this:
import { Pipe, PipeTransform } from '@angular/core';
import { TranslatePipe } from "@ngx-translate/core";
@Pipe({
name: 'msg'
})
export class MsgPipe extends TranslatePipe implements PipeTransform {
transform(value: any, args: any[]): any {
return super.transform(value, args)
}
}
It seems that this only works when the pure property is set to false. It appears that the loader for ngx-translate may not be fully prepared yet. Is there a way to verify this? If so, I could maintain the purity of the pipe while ensuring its functionality.
Original post (not relevant):
I have developed a pipe that simply utilizes translateService.instant and outputs the result.
@Pipe({
name: 'msg',
pure: false
})
export class MsgPipe implements PipeTransform {
constructor(private translateService: TranslateService) {}
transform(value: any, args: any[]): any {
console.log('checked. val = ', value)
return this.translateService.instant(value, args);
}
}
If I do not mark this as pure: false, the pipe only returns the initial value. By setting it, the desired outcome is achieved (assuming the file loader has been completed).
My concern is that each pipe call results in approximately 8 executions. Is there a way to optimize change detection to indicate to the pipe to cease checking once the value has been obtained?