Answer the question
In order to leave comments, you need to log in
How can the code section be improved?
ngAfterViewInit() {
combineLatest(...this.filtersList.map((f) => f.filtersChanges)).subscribe(
(selectedFilters) => {
const filterUrlCombiner = new FilterUrlCombiner();
const filterUrlBuilders = selectedFilters.map((filter) => new FilterUrlBuilder(filter, ComparingOperation.eq));
filterUrlBuilders.forEach((filter) => {
filter.buildStringUrl();
});
const filterUrls = filterUrlBuilders.filter((filter) => filter.url).map((filter) => filter.url);
filterUrlCombiner.combineUrl(filterUrls);
this.filterBy = filterUrlCombiner.getUrl();
this.settingsService.setDistributionFiltersSettings(selectedFilters);
setTimeout(
() => (this.buttonDisabled = !selectedFilters.some((item) => item && item.selected && item.selected.length > 0)),
);
},
(error) => {
console.log('ERROR: ' + error);
},
);
}
filterUrlCombiner.combineUrl(filterUrls);
this.filterBy = filterUrlCombiner.getUrl();
Answer the question
In order to leave comments, you need to log in
filterUrlBuilders.filter((filter) => filter.url).map((filter) => filter.url);
filterUrlBuilders.map(filter => filter.url).filter(Boolean);
FilterUrlCombiner
and FilterUrlBuilder
: are they really needed and do some useful work or does someone have an enterprise brain?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question