Skip to content

Commit

Permalink
add take(1) to pipe to ensure subscription will end
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone committed May 23, 2024
1 parent 53d513e commit b54ab72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import { UploadedFile, UploadFileService } from '@dasch-swiss/vre/shared/app-resource-properties';
import { Store } from '@ngxs/store';
import { ProjectsSelectors } from '@dasch-swiss/vre/shared/app-state';
import { filter, map, mergeMap } from 'rxjs/operators';
import { filter, map, mergeMap, take } from 'rxjs/operators';
import { AppConfigService } from '@dasch-swiss/vre/shared/app-config';

// https://stackoverflow.com/questions/45661010/dynamic-nested-reactive-form-expressionchangedafterithasbeencheckederror
Expand Down Expand Up @@ -99,6 +99,7 @@ export class UploadComponent implements OnInit {

this._store.select(ProjectsSelectors.currentProject).pipe(
filter(v => v !== undefined),
take(1),
map(prj=> prj.shortcode),
mergeMap(sc => this._upload.upload(this.file, sc))
).subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {fileValueMapping} from './file-value-mapping';
import { UploadedFile, UploadFileService } from './upload-file.service';
import {Store} from "@ngxs/store";
import {ProjectsSelectors} from "@dasch-swiss/vre/shared/app-state";
import {filter, map, mergeMap} from "rxjs/operators";
import { filter, map, mergeMap, take } from 'rxjs/operators';

@Component({
selector: 'app-upload-2',
Expand Down Expand Up @@ -123,6 +123,7 @@ export class Upload2Component implements ControlValueAccessor {
private _uploadFile(file: File): void {
this._store.select(ProjectsSelectors.currentProject).pipe(
filter(v => v !== undefined),
take(1),
map(prj=> prj.shortcode),
mergeMap(sc => this._upload.upload(file, sc))
).subscribe((res: UploadedFile) => {
Expand Down

0 comments on commit b54ab72

Please sign in to comment.