From afdc3cda3719325b8df001e37c763dff08da1f94 Mon Sep 17 00:00:00 2001 From: Matteo Velludini Date: Thu, 30 Mar 2017 17:17:17 +0200 Subject: [PATCH] fixed indentation --- web/client/epics/search.js | 52 +++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/web/client/epics/search.js b/web/client/epics/search.js index ec6127cc10..f159ea6acd 100644 --- a/web/client/epics/search.js +++ b/web/client/epics/search.js @@ -42,32 +42,31 @@ const searchEpic = action$ => action$.ofType(TEXT_SEARCH_STARTED) .debounceTime(250) .switchMap( action => - // create a stream of streams from array - Rx.Observable.from( - (action.services || [ {type: "nominatim"} ]) - // Create an stream for each Service - .map((service) => - Rx.Observable.defer(() => - API.Utils.getService(service.type)(action.searchText, service.options) - .then( (response= []) => response.map(result => ({...result, __SERVICE__: service, __PRIORITY__: service.priority || 0})) - )) - .retryWhen(errors => errors.delay(200).scan((count, err) => { - if ( count >= 2) { - throw err; - } - return count + 1; - }, 0)) - ) // map - ) // from - // merge all results from the streams - .mergeAll() - .scan( (oldRes, newRes) => [...oldRes, ...newRes].sort( (a, b) => get(b, "__PRIORITY__") - get(a, "__PRIORITY__") ) .slice(0, 15)) - .map((results) => searchResultLoaded(results, false)) - .takeUntil(action$.ofType([ TEXT_SEARCH_RESULTS_PURGE, TEXT_SEARCH_RESET, TEXT_SEARCH_ITEM_SELECTED])) - .startWith(searchTextLoading(true)) - .concat([searchTextLoading(false)]) - .catch(e => Rx.Observable.from([searchResultError(e), searchTextLoading(false)])) - + // create a stream of streams from array + Rx.Observable.from( + (action.services || [ {type: "nominatim"} ]) + // Create an stream for each Service + .map((service) => + Rx.Observable.defer(() => + API.Utils.getService(service.type)(action.searchText, service.options) + .then( (response= []) => response.map(result => ({...result, __SERVICE__: service, __PRIORITY__: service.priority || 0})) + )) + .retryWhen(errors => errors.delay(200).scan((count, err) => { + if ( count >= 2) { + throw err; + } + return count + 1; + }, 0)) + ) // map + ) // from + // merge all results from the streams + .mergeAll() + .scan( (oldRes, newRes) => [...oldRes, ...newRes].sort( (a, b) => get(b, "__PRIORITY__") - get(a, "__PRIORITY__") ) .slice(0, 15)) + .map((results) => searchResultLoaded(results, false)) + .takeUntil(action$.ofType([ TEXT_SEARCH_RESULTS_PURGE, TEXT_SEARCH_RESET, TEXT_SEARCH_ITEM_SELECTED])) + .startWith(searchTextLoading(true)) + .concat([searchTextLoading(false)]) + .catch(e => Rx.Observable.from([searchResultError(e), searchTextLoading(false)])) ); /** @@ -86,6 +85,7 @@ const searchEpic = action$ => const searchItemSelected = action$ => action$.ofType(TEXT_SEARCH_ITEM_SELECTED) .switchMap(action => { + // itemSelectionStream --> emits actions for zoom and marker add let itemSelectionStream = Rx.Observable.of(action.item) .concatMap((item) => { if (item && item.__SERVICE__ && item.__SERVICE__.geomService) {