Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
derschnee68 committed Feb 26, 2025
1 parent 6a642d6 commit 25f8705
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnChanges, OnDestroy } from '@angular/core';
import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
import { ResourceFetcherService } from '@dasch-swiss/vre/resource-editor/representations';
import { DspResource } from '@dasch-swiss/vre/shared/app-common';
import { Subject } from 'rxjs';
Expand All @@ -17,7 +17,7 @@ import { takeUntil } from 'rxjs/operators';
`,
providers: [ResourceFetcherService],
})
export class ResourceFetcherComponent implements OnChanges, OnDestroy {
export class ResourceFetcherComponent implements OnInit, OnChanges, OnDestroy {
@Input({ required: true }) resourceIri!: string;

resource?: DspResource;
Expand All @@ -26,13 +26,7 @@ export class ResourceFetcherComponent implements OnChanges, OnDestroy {

constructor(private _resourceFetcherService: ResourceFetcherService) {}

ngOnChanges() {
this.loading = true;
this._resourceFetcherService.onDestroy();
this._resourceFetcherService.onInit(this.resourceIri);

this._unsubscribe();

ngOnInit() {
this._resourceFetcherService.resource$.pipe(takeUntil(this._ngUnsubscribe)).subscribe(resource => {
if (resource === null) {
return;
Expand All @@ -53,6 +47,12 @@ export class ResourceFetcherComponent implements OnChanges, OnDestroy {
});
}

ngOnChanges() {
this.loading = true;
this._resourceFetcherService.onDestroy();
this._resourceFetcherService.onInit(this.resourceIri);
}

ngOnDestroy() {
this._resourceFetcherService.onDestroy();
this._unsubscribe();
Expand Down

0 comments on commit 25f8705

Please sign in to comment.