-
Notifications
You must be signed in to change notification settings - Fork 343
/
Copy pathreducer.ts
41 lines (32 loc) · 864 Bytes
/
reducer.ts
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
import { createReducer } from 'redux-act'
import * as acts from './actions'
export interface State {
/** Holds the tab ID which the popup is currently shown in. */
tabId: number
/** Holds the URL of the page which the popup is currently shown in. */
url: string
/** Holds the current state of the search input. */
searchValue: string
}
export const defState: State = {
tabId: null,
url: '',
searchValue: '',
}
const reducer = createReducer<State>({}, defState)
reducer.on(acts.setTabId, (state, payload) => ({
...state,
tabId: payload,
}))
reducer.on(acts.openSidebar as any, (state) => ({
...state,
}))
reducer.on(acts.setUrl, (state, payload) => ({
...state,
url: payload,
}))
reducer.on(acts.setSearchVal, (state, payload) => ({
...state,
searchValue: payload,
}))
export default reducer