Skip to content

Commit

Permalink
fixed indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Mar 30, 2017
1 parent 28ba27a commit afdc3cd
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions web/client/epics/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)]))
);

/**
Expand All @@ -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) {
Expand Down

0 comments on commit afdc3cd

Please sign in to comment.