🦊 small fit to fetcher 🦊 (#87)

This commit is contained in:
Alexandra Usacheva 2019-09-23 12:39:47 +03:00 committed by GitHub
parent 7f8bad30c3
commit 8a348da8ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -2,3 +2,4 @@ export * from './map-to-shop-info';
export * from './filter-shops-by-env';
export * from './map-to-timestamp';
export * from './negate-env';
export * from './remove-empty-properties';

View File

@ -0,0 +1,4 @@
import isNil from 'lodash.isnil';
export const removeEmptyProperties = <T>(obj: T): T =>
Object.keys(obj).reduce((acc, cur) => (!isNil(obj[cur]) ? { ...acc, [cur]: obj[cur] } : acc), {} as T);

View File

@ -12,7 +12,7 @@ import { toFormValue } from './to-form-value';
import { SearchFormValue } from '../../search-form-value';
import { ShopService } from '../../../../../api';
import { takeRouteParam } from '../../../../../custom-operators';
import { mapToShopInfo, ShopInfo, filterShopsByEnv } from '../../operators';
import { mapToShopInfo, ShopInfo, filterShopsByEnv, removeEmptyProperties } from '../../operators';
@Injectable()
export class SearchFormService {
@ -47,6 +47,7 @@ export class SearchFormService {
formValueChanges(valueDebounceTime: number): Observable<PaymentSearchFormValue> {
return this.searchForm.valueChanges.pipe(
filter(() => this.searchForm.status === 'VALID'),
removeEmptyProperties,
debounceTime(valueDebounceTime)
);
}