Skip to content

Commit

Permalink
chore: revert switchMapTos back to switchMap
Browse files Browse the repository at this point in the history
this change looks forward to rxjs v8
for more info see ReactiveX/rxjs#6399
  • Loading branch information
bglamadrid committed Apr 4, 2022
1 parent f0faa3a commit 828d81a
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/app/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Inject, Injectable, OnDestroy } from '@angular/core';
import { of, Subject } from 'rxjs';
import { switchMap, switchMapTo, take, tap } from 'rxjs/operators';
import { switchMap, take, tap } from 'rxjs/operators';
import { API_INJECTION_TOKENS } from 'src/app/api/api-injection-tokens';
import { ILoginPublicApiService } from 'src/app/api/login-public-api.iservice';
import { Person } from 'src/models/entities/Person';
Expand Down Expand Up @@ -52,8 +52,8 @@ export class AuthenticationService
register(userDetails: Registration) {
return this.sessionService.userHasActiveSession$.pipe(
take(1),
switchMapTo(this.registerApiService.register(userDetails)),
switchMapTo(this.loginApiService.login({
switchMap(() => this.registerApiService.register(userDetails)),
switchMap(() => this.loginApiService.login({
name: userDetails.name,
password: userDetails.password
})),
Expand Down
4 changes: 2 additions & 2 deletions src/app/authorization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Inject, Injectable, OnDestroy } from '@angular/core';
import { BehaviorSubject, interval, merge, Observable, of, Subscription } from 'rxjs';
import { catchError, filter, mapTo, switchMap, switchMapTo, take, takeUntil, tap } from 'rxjs/operators';
import { catchError, filter, mapTo, switchMap, take, takeUntil, tap } from 'rxjs/operators';
import { API_INJECTION_TOKENS } from 'src/app/api/api-injection-tokens';
import { environment } from 'src/environments/environment';
import { AuthorizedAccess } from 'src/models/AuthorizedAccess';
Expand Down Expand Up @@ -71,7 +71,7 @@ export class AuthorizationService
interval(this.authorizationUpdateInterval)
).pipe(
takeUntil(this.sessionService.userHasActiveSession$.pipe(filter(isActive => !isActive))),
switchMapTo(this.accessApiService.getAuthorizedAccess()),
switchMap(() => this.accessApiService.getAuthorizedAccess()),
tap(access => { this.authorizedAccessSource.next(access); }),
mapTo(true)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Component, Inject, OnDestroy } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { BehaviorSubject, Observable, Subscription, throwError } from 'rxjs';
import { catchError, finalize, switchMapTo, tap } from 'rxjs/operators';
import { catchError, finalize, tap } from 'rxjs/operators';
import { COMMON_DISMISS_BUTTON_LABEL, COMMON_ERROR_MESSAGE } from 'src/text/messages';
import { SELL_STATUS_NAMES_MAP } from 'src/text/sell-status-names';
import { ManagementSalesService } from '../../routes/sales/management-sales.service';
Expand Down Expand Up @@ -74,7 +74,7 @@ export class ManagementSellReviewDialogComponent
this.salesService.reloadItems();
this.snackBarService.open(successMessage, COMMON_DISMISS_BUTTON_LABEL);
}),
switchMapTo(this.salesService.fetch(this.data.sell)),
switchMap(() => this.salesService.fetch(this.data.sell)),
tap(next => this.data.sell = next),
catchError(err => {
this.snackBarService.open(COMMON_ERROR_MESSAGE, COMMON_DISMISS_BUTTON_LABEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Directive } from '@angular/core';
import { forkJoin, Observable, of } from 'rxjs';
import { catchError, filter, finalize, mapTo, switchMapTo } from 'rxjs/operators';
import { catchError, filter, finalize, mapTo } from 'rxjs/operators';
import { ITransactionalEntityDataApiService } from 'src/app/api/transactional-entity.data-api.iservice';
import { SharedDialogService } from 'src/app/shared/dialogs/shared-dialog.service';
import { DataManagerServiceDirective } from '../data-manager/data-manager.service.directive';
Expand All @@ -32,7 +32,7 @@ export abstract class TransactionalDataManagerServiceDirective<T>
message: $localize`:Paragraph asking confirmation to delete a portion of data, reminding that it cannot be undone:Are you sure you want to delete this item?`
}).pipe(
filter(didConfirm => didConfirm),
switchMapTo(forkJoin(items.map(item => (
switchMap(() => forkJoin(items.map(item => (
this.dataService.delete(item).pipe(
mapTo(true),
catchError(() => of(false))
Expand Down
8 changes: 4 additions & 4 deletions src/app/management/routes/sales/management-sales.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { Inject, Injectable } from '@angular/core';
import { filter, switchMapTo } from 'rxjs/operators';
import { filter } from 'rxjs/operators';
import { API_INJECTION_TOKENS } from 'src/app/api/api-injection-tokens';
import { ISalesDataApiService } from 'src/app/api/sales.data.api.iservice';
import { SharedDialogService } from 'src/app/shared/dialogs/shared-dialog.service';
Expand All @@ -30,7 +30,7 @@ export class ManagementSalesService
message: $localize`:Label to hint user that rejections cannot be undone, and they do not trigger automatic refunds:The sell will remain read-only. Any refunds will have to be issued manually. This operation cannot be undone. Are you sure you want to reject this order?`
}).pipe(
filter(didConfirm => !!didConfirm),
switchMapTo(this.dataService.markAsRejected(sell as Sell))
switchMap(() => this.dataService.markAsRejected(sell as Sell))
);
}

Expand All @@ -40,7 +40,7 @@ export class ManagementSalesService
message: $localize`:Label to hint user that confirmations cannot be undone, and they trigger an automatic mail to the customer:The customer will be notified and sent a receipt by e-mail. This operation cannot be undone. Are you sure you want to confirm this order?`
}).pipe(
filter(didConfirm => !!didConfirm),
switchMapTo(this.dataService.markAsConfirmed(sell as Sell))
switchMap(() => this.dataService.markAsConfirmed(sell as Sell))
);
}

Expand All @@ -50,7 +50,7 @@ export class ManagementSalesService
message: $localize`:Label to hint user that completions cannot be undone:The sell will remain read-only. This operation cannot be undone. Are you sure you want to mark this order as completed?`
}).pipe(
filter(didConfirm => !!didConfirm),
switchMapTo(this.dataService.markAsCompleted(sell as Sell))
switchMap(() => this.dataService.markAsCompleted(sell as Sell))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTree, MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
import { Observable, Subscription } from 'rxjs';
import { debounceTime, filter, switchMap, switchMapTo, tap } from 'rxjs/operators';
import { debounceTime, filter, switchMap, tap } from 'rxjs/operators';
import { ProductCategory } from 'src/models/entities/ProductCategory';
import { COMMON_DISMISS_BUTTON_LABEL } from 'src/text/messages';
import { EntityFormDialogComponent } from '../../../management/dialogs/entity-form/entity-form-dialog.component';
Expand Down Expand Up @@ -117,7 +117,7 @@ export class ProductCategoryTreeComponent
message: $localize`:Paragraph asking confirmation to delete a category, and explaining that deleting it cascades to its descendants, but not to related products which are detached from the relationship:Are you sure to delete the category? This will include all its descendants. Related products will not be deleted, and instead will be marked as not having a category.`
}).pipe(
filter(didConfirm => didConfirm),
switchMapTo(this.service.deleteNode(node)),
switchMap(() => this.service.deleteNode(node)),
tap(() => this.matTree.renderNodeChanges(this.dataSource.data)) // TODO optimize this?
).subscribe(
next => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Observable, of } from 'rxjs';
import { filter, map, switchMap, switchMapTo, take, tap } from 'rxjs/operators';
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
import { AuthorizationService } from 'src/app/authorization.service';
import { ProfileService } from 'src/app/profile.service';
import { SessionService } from 'src/app/session.service';
Expand Down Expand Up @@ -62,7 +62,7 @@ export class StoreHeaderMenuComponent
this.sessionService.userHasActiveSession$.pipe(
take(1),
filter(hasActiveSession => hasActiveSession),
switchMapTo(this.confirmLogout()),
switchMap(() => this.confirmLogout()),
filter(didConfirm => didConfirm),
tap(() => {
this.sessionService.closeCurrentSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { debounceTime, switchMapTo, tap } from 'rxjs/operators';
import { debounceTime, tap } from 'rxjs/operators';
import { ProductCategoryPickerDialogComponent } from 'src/app/shared/dialogs/product-category-picker/product-category-picker-dialog.component';
import { ProductSearchQuery } from 'src/models/ProductSearchQuery';
import { StoreSearchService } from '../../../store-search.service';
Expand Down Expand Up @@ -51,7 +51,7 @@ export class StoreHeaderSearchFormComponent
this.searchService.searchQuery = (value as ProductSearchQuery);
this.searchService.pageIndex = 0;
}),
switchMapTo(this.searchService.reload())
switchMap(() => this.searchService.reload())
).subscribe();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
import { MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { BehaviorSubject, Observable, Subject, throwError } from 'rxjs';
import { catchError, map, switchMapTo, takeUntil, tap } from 'rxjs/operators';
import { catchError, map, takeUntil, tap } from 'rxjs/operators';
import { AuthenticationService } from 'src/app/authentication.service';
import { ProfileService } from 'src/app/profile.service';
import { DialogSwitcherButtonComponent } from 'src/app/shared/components/dialog-switcher-button/dialog-switcher-button.component';
Expand Down Expand Up @@ -91,7 +91,7 @@ export class StoreLoginFormDialogComponent
this.loggingInSource.next(false);
return throwError(err);
}),
switchMapTo(this.profileService.getUserProfile())
switchMap(() => this.profileService.getUserProfile())
).subscribe();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Observable, Subject, Subscription } from 'rxjs';
import { map, startWith, switchMapTo, take, tap } from 'rxjs/operators';
import { map, startWith, take, tap } from 'rxjs/operators';
import { StoreCartService } from '../../store-cart.service';
import { StoreProductDetailsDialogData } from './StoreProductDetailsDialogData';

Expand All @@ -35,7 +35,7 @@ export class StoreProductDetailsDialogComponent
ngOnInit(): void {
this.productUnitsInCart$ = this.selfChangeTrigger.pipe(
startWith(void 0),
switchMapTo(this.cartService.cartDetails$.pipe(take(1))),
switchMap(() => this.cartService.cartDetails$.pipe(take(1))),
map(details => details[this.matchingCartIndex]),
map(d => (d ? d.units : 0))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
import { MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { BehaviorSubject, throwError } from 'rxjs';
import { catchError, switchMapTo, takeUntil, tap } from 'rxjs/operators';
import { catchError, takeUntil, tap } from 'rxjs/operators';
import { AuthenticationService } from 'src/app/authentication.service';
import { ProfileService } from 'src/app/profile.service';
import { EntityFormGroupFactoryService } from 'src/app/shared/entity-form-group-factory.service';
Expand Down Expand Up @@ -86,7 +86,7 @@ export class StoreRegistrationFormDialogComponent
this.registeringSource.next(false);
return throwError(err);
}),
switchMapTo(this.profileService.getUserProfile())
switchMap(() => this.profileService.getUserProfile())
).subscribe();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/store/store-search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Inject, Injectable, OnDestroy } from "@angular/core";
import { PageEvent } from "@angular/material/paginator";
import { ActivatedRoute, Router } from "@angular/router";
import { BehaviorSubject, from, ReplaySubject } from "rxjs";
import { switchMapTo, tap } from "rxjs/operators";
import { tap } from "rxjs/operators";
import { DataPage } from "src/models/DataPage";
import { Product } from "src/models/entities/Product";
import { ProductSearchQuery } from "src/models/ProductSearchQuery";
Expand Down Expand Up @@ -80,7 +80,7 @@ export class StoreSearchService
}
)).pipe(
tap(() => this.isLoadingSearchSource.next(true)),
switchMapTo(this.productsApiService.fetchPage(this.pageIndex, this.pageSize, this.sortBy, this.order, finalFilterObject)),
switchMap(() => this.productsApiService.fetchPage(this.pageIndex, this.pageSize, this.sortBy, this.order, finalFilterObject)),
tap(page => {
this.currentPageSource.next(page);
this.isLoadingSearchSource.next(false);
Expand Down

0 comments on commit 828d81a

Please sign in to comment.