Skip to content

Commit

Permalink
chore: switch to translationService stream
Browse files Browse the repository at this point in the history
  • Loading branch information
illfixit committed Oct 2, 2024
1 parent 306d015 commit 6e0f1e2
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Input, OnChanges, OnDestroy, OnInit} from '@angular/core';
import {Component, Input, OnChanges, OnDestroy} from '@angular/core';
import {Subject, switchMap} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {TranslateService} from '@ngx-translate/core';
Expand All @@ -8,9 +8,7 @@ import {SimpleChangesTyped} from '../../../core/utils/angular-utils';
selector: 'translate-with-slot',
templateUrl: './translate-with-slot.component.html',
})
export class TranslateWithSlotComponent
implements OnInit, OnChanges, OnDestroy
{
export class TranslateWithSlotComponent implements OnChanges, OnDestroy {
@Input()
key!: string;

Expand All @@ -27,14 +25,10 @@ export class TranslateWithSlotComponent
this.splitText();
}

ngOnInit() {
this.splitText();
}

splitText() {
this.key$
.pipe(
switchMap(() => this.translationService.get(this.key)),
switchMap(() => this.translationService.stream(this.key)),
takeUntil(this.ngOnDestroy$),
)
.subscribe((text) => {
Expand Down

0 comments on commit 6e0f1e2

Please sign in to comment.