forked from WebMemex/webmemex-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepics.js
24 lines (19 loc) · 857 Bytes
/
epics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import 'rxjs/add/operator/debounceTime'
import 'rxjs/add/operator/map'
import 'rxjs/add/operator/filter'
import * as actions from './actions'
const searchUpdateActions = [
actions.setQuery.getType(),
actions.setStartDate.getType(),
actions.setEndDate.getType(),
]
// When the query changed, refresh the search results
export const refreshSearchResultsUponQueryChange = action$ => action$
.filter(action => searchUpdateActions.includes(action.type))
.debounceTime(500) // wait until typing stops for 500ms
.map(() => actions.refreshSearch({loadingIndicator: true}))
// When the database changed, refresh the search results
export const refreshSearchResultsUponLogChange = action$ => action$
.ofType(actions.handlePouchChange.getType())
.debounceTime(1000)
.map(() => actions.refreshSearch({loadingIndicator: false}))