Skip to content

Commit

Permalink
chore: do not use mapTos variants
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 828d81a commit 19ab816
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Injectable } from '@angular/core';
import { Observable, of, throwError } from 'rxjs';
import { mapTo, tap } from 'rxjs/operators';
import { map, tap } from 'rxjs/operators';
import { ProductCategory } from 'src/models/entities/ProductCategory';
import { matchesDateProperty, matchesIdProperty, matchesNumberProperty, matchesStringProperty } from '../entity-data.local-memory-api.functions';
import { MOCK_PRODUCT_CATEGORIES } from '../mock/mock-product-categories.datasource';
Expand Down Expand Up @@ -38,7 +38,7 @@ export class ProductCategoriesDataLocalMemoryApiService
) :
of()
).pipe(
mapTo(void 0),
map(() => void 0),
tap(() => this.items.push(item))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Inject, Injectable } from '@angular/core';
import { from, Observable, of, throwError } from 'rxjs';
import { mapTo, switchMap, tap, toArray } from 'rxjs/operators';
import { switchMap, tap, toArray } from 'rxjs/operators';
import { paginateItems } from 'src/functions/paginateItems';
import { DataPage } from 'src/models/DataPage';
import { Product } from 'src/models/entities/Product';
Expand Down Expand Up @@ -96,7 +96,7 @@ export class ProductListsDataLocalMemoryApiService
fullListContents.add(p);
list.totalCount = fullListContents.size;
}),
mapTo(void 0)
map(() => void 0)
);
}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ export class ProductListsDataLocalMemoryApiService
this.itemContentsMap.set(list.code, new Set(products));
list.totalCount = products.length;
}),
mapTo(void 0)
map(() => void 0)
);
}
}
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, take, takeUntil, tap } from 'rxjs/operators';
import { catchError, filter, map, 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 @@ -73,7 +73,7 @@ export class AuthorizationService
takeUntil(this.sessionService.userHasActiveSession$.pipe(filter(isActive => !isActive))),
switchMap(() => this.accessApiService.getAuthorizedAccess()),
tap(access => { this.authorizedAccessSource.next(access); }),
mapTo(true)
map(() => true)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSelectionListChange } from '@angular/material/list';
import { PageEvent } from '@angular/material/paginator';
import { from, merge, Observable, Subject, Subscription } from 'rxjs';
import { debounceTime, map, mapTo, tap, throttleTime } from 'rxjs/operators';
import { debounceTime, map, tap, throttleTime } from 'rxjs/operators';
import { Image } from 'src/models/entities/Image';
import { ImageArrayOption } from './ImageArrayOption';
import { ImagesArrayService } from './images-array.service';
Expand Down Expand Up @@ -47,7 +47,7 @@ export class ImagesArrayDialogComponent

ngOnInit(): void {
this.loading$ = merge(
this.filterChangeNotifier.pipe(mapTo(true)),
this.filterChangeNotifier.pipe(map(() => true)),
this.service.loading$.pipe()
);
this.options$ = this.service.imagesPage$.pipe(
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, tap } from 'rxjs/operators';
import { catchError, finalize, switchMap, 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
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 } from 'rxjs/operators';
import { catchError, filter, finalize, map, switchMap } 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 @@ -34,7 +34,7 @@ export abstract class TransactionalDataManagerServiceDirective<T>
filter(didConfirm => didConfirm),
switchMap(() => forkJoin(items.map(item => (
this.dataService.delete(item).pipe(
mapTo(true),
map(() => true),
catchError(() => of(false))
)
)))),
Expand Down
4 changes: 2 additions & 2 deletions src/app/management/management.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { Injectable, OnDestroy } from '@angular/core';
import { ActivatedRoute, ActivationEnd, Router } from '@angular/router';
import { BehaviorSubject, ReplaySubject, Subscription } from 'rxjs';
import { filter, map, mapTo, tap, throttleTime } from 'rxjs/operators';
import { filter, map, tap, throttleTime } from 'rxjs/operators';

/**
* Keeps track of general shared data in the management module, such as the sidenav state and the name of the active path
Expand Down Expand Up @@ -47,7 +47,7 @@ export class ManagementService
return this.router.events.pipe(
filter(ev => ev instanceof ActivationEnd),
throttleTime(50),
mapTo(this.route.snapshot)
map(() => this.route.snapshot)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { Inject, Injectable } from '@angular/core';
import { filter } from 'rxjs/operators';
import { filter, switchMap } 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 Down
4 changes: 2 additions & 2 deletions src/app/session.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, Observable, of, ReplaySubject } from 'rxjs';
import { catchError, finalize, mapTo, tap } from 'rxjs/operators';
import { catchError, finalize, map, tap } from 'rxjs/operators';
import { API_INJECTION_TOKENS } from 'src/app/api/api-injection-tokens';
import { environment } from 'src/environments/environment';
import { IAccessApiService } from './api/access-api.iservice';
Expand Down Expand Up @@ -42,7 +42,7 @@ export class SessionService
this.isValidatingSessionSource.next(true);

return this.accessApiService.getAuthorizedAccess().pipe(
mapTo(true),
map(() => true),
catchError(() => of(false)),
tap(isValid => { this.userHasActiveSessionSource.next(isValid); }),
finalize(() => { this.isValidatingSessionSource.next(false); })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { BehaviorSubject, concat, Observable, Subscription, throwError } from 'rxjs';
import { catchError, finalize, map, mapTo, startWith, tap } from 'rxjs/operators';
import { catchError, finalize, map, startWith, tap } from 'rxjs/operators';
import { isJavaScriptObject } from 'src/functions/isJavaScriptObject';
import { COMMON_DISMISS_BUTTON_LABEL } from 'src/text/messages';
import { ImageManagerUploadService } from './image-upload-form.service';
Expand Down Expand Up @@ -172,6 +172,6 @@ export class ImageUploadFormComponent
);
}
}
return uploads$.pipe(mapTo(void 0));
return uploads$.pipe(map(() => void 0));
}
}
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, forkJoin, Observable, of, Subscription } from 'rxjs';
import { map, mapTo, switchMap, tap } from 'rxjs/operators';
import { map, switchMap, tap } from 'rxjs/operators';
import { API_INJECTION_TOKENS } from 'src/app/api/api-injection-tokens';
import { ITransactionalEntityDataApiService } from 'src/app/api/transactional-entity.data-api.iservice';
import { ProductCategory } from 'src/models/entities/ProductCategory';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class ProductCategoryTreeService
}
this.categoriesSource.next(this.categoriesSource.value);
}),
mapTo(target)
map(() => target)
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/components/slideshow/slideshow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Component, EventEmitter, forwardRef, Input, OnDestroy, OnInit, Output,
import { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR } from '@angular/forms';
import { Router } from '@angular/router';
import { BehaviorSubject, interval, merge, Observable, Subscription } from 'rxjs';
import { debounceTime, delay, mapTo, tap } from 'rxjs/operators';
import { debounceTime, delay, map, tap } from 'rxjs/operators';
import { fadeInOut } from 'src/animations/fadeInOut';
import { Image } from 'src/models/entities/Image';

Expand Down Expand Up @@ -156,7 +156,7 @@ export class SlideshowComponent
private autoImageRotationObservable(): Observable<void> {
return interval(this.autoRotationInterval).pipe(
tap(() => { this.slideForwards(); }),
mapTo(void 0)
map(() => void 0)
);
}

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, tap } from 'rxjs/operators';
import { debounceTime, switchMap, 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Component, Inject, OnInit } from '@angular/core';
import { ReplaySubject, Subject } from 'rxjs';
import { mapTo, pluck, startWith } from 'rxjs/operators';
import { map, pluck, startWith } from 'rxjs/operators';
import { IAboutPublicApiService } from 'src/app/api/about-public-api.iservice';
import { API_INJECTION_TOKENS } from 'src/app/api/api-injection-tokens';
import { CompanyDetails } from 'src/models/CompanyDetails';
Expand All @@ -22,8 +22,9 @@ export class StoreCompanyDetailsDialogComponent

private dataSource: Subject<CompanyDetails> = new ReplaySubject();

// TODO move these observables
data$ = this.dataSource.asObservable();
loading$ = this.data$.pipe(mapTo(false), startWith(true));
loading$ = this.data$.pipe(map(() => false), startWith(true));
name$ = this.data$.pipe(pluck('name'));
description$ = this.data$.pipe(pluck('description'));
// bannerURL$ = this.data$.pipe(pluck('bannerImageURL'));
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, takeUntil, tap } from 'rxjs/operators';
import { catchError, map, switchMap, 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
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, take, tap } from 'rxjs/operators';
import { map, startWith, switchMap, take, tap } from 'rxjs/operators';
import { StoreCartService } from '../../store-cart.service';
import { StoreProductDetailsDialogData } from './StoreProductDetailsDialogData';

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, takeUntil, tap } from 'rxjs/operators';
import { catchError, switchMap, 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
2 changes: 1 addition & 1 deletion 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 { tap } from "rxjs/operators";
import { switchMap, 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

0 comments on commit 19ab816

Please sign in to comment.