forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessy.ts
More file actions
50 lines (41 loc) · 1.01 KB
/
messy.ts
File metadata and controls
50 lines (41 loc) · 1.01 KB
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
export default (ts) =>
ts
? [
{
fileName: 'overmind/actions.ts',
code: `
import { Action } from 'overmind'
let debounce
export const search: Action<Event> = ({ state, effects }, event) => {
state.query = event.currentTarget.value
if (query.length < 3) return
if (debounce) clearTimeout(debounce)
debounce = setTimeout(async () => {
state.isSearching = true
state.searchResult = await effects.api.search(state.query)
state.isSearching = false
debounce = null
}, 200)
}
`,
},
]
: [
{
fileName: 'overmind/state.js',
code: `
let debounce
export const search = ({ state, effects }, event) => {
state.query = event.currentTarget.value
if (query.length < 3) return
if (debounce) clearTimeout(debounce)
debounce = setTimeout(async () => {
state.isSearching = true
state.searchResult = await effects.api.search(state.query)
state.isSearching = false
debounce = null
}, 200)
}
`,
},
]