1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
//import * as R from 'ramda';
const ADD_SEARCH_INTERESTED_PARTY = 'ADD_SEARCH_INTERESTED_PARTY';
const REMOVE_SEARCH_INTERESTED_PARTY = 'REMOVE_SEARCH_INTERESTED_PARTY';
const SET_SEARCH_TERM = 'SET_SEARCH_TERM';
const SET_SEARCH_AUTO_COMPLETE_TERM = 'SET_SEARCH_AUTO_COMPLETE_TERM';
const RESET_SEARCH_AUTO_COMPLETE_FUTURE = 'RESET_SEARCH_AUTO_COMPLETE_FUTURE';
const SET_SEARCH_AUTO_COMPLETE_FUTURE = 'SET_SEARCH_AUTO_COMPLETE_FUTURE';
const AUTO_COMPLETE_DELAY = 300; // miliseconds.
function addSearchInterestedParty(listener) {
return {
type: ADD_SEARCH_INTERESTED_PARTY,
payload: {
listener: listener
}
};
}
function removeSearchInterestedParty(listener) {
return {
type: REMOVE_SEARCH_INTERESTED_PARTY,
payload: {
listener: listener
}
};
}
function setSearchTerm(searchTerm) {
return {
type: SET_SEARCH_TERM,
payload: {
searchTerm: searchTerm
}
};
}
function setSearchAutoCompleteTerm(searchTerm) {
return {
type: SET_SEARCH_AUTO_COMPLETE_TERM,
payload: {
searchTerm: searchTerm
}
};
}
function resetSearchAutoCompleteFuture() {
return {
type: RESET_SEARCH_AUTO_COMPLETE_FUTURE,
};
}
function setSearchAutoCompleteFuture(futureId) {
return {
type: SET_SEARCH_AUTO_COMPLETE_FUTURE,
payload: {
futureId: futureId
}
};
}
function notifySearchAutoCompleteTermChanged(searchTerm) {
return (dispatch) => {
let autoCompleteFutureId = setTimeout(() => {
dispatch(resetSearchAutoCompleteFuture());
dispatch(setSearchAutoCompleteTerm(searchTerm));
}, AUTO_COMPLETE_DELAY);
dispatch(setSearchAutoCompleteFuture(autoCompleteFutureId));
};
}
export {
ADD_SEARCH_INTERESTED_PARTY,
REMOVE_SEARCH_INTERESTED_PARTY,
SET_SEARCH_TERM,
SET_SEARCH_AUTO_COMPLETE_TERM,
RESET_SEARCH_AUTO_COMPLETE_FUTURE,
SET_SEARCH_AUTO_COMPLETE_FUTURE,
addSearchInterestedParty,
removeSearchInterestedParty,
setSearchTerm,
setSearchAutoCompleteTerm,
notifySearchAutoCompleteTermChanged
};
|