forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompute.ts
More file actions
50 lines (44 loc) · 1.11 KB
/
compute.ts
File metadata and controls
50 lines (44 loc) · 1.11 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: 'app/computed.ts',
code: `
import { Compute } from 'overmind'
import { Item } from './state'
export const filteredItems: Compute<string, Item[]> = filterNameBy => state =>
state.items.filter(item => item.name === filterNameBy)
`,
},
{
fileName: 'app/state.ts',
code: `
import { compute } from 'overmind'
import * as computed from './computed'
export type Item = {
name: string
}
export const items: Item[] = []
export const filteredItems: (input: string) => Item[] =
compute(computed.filteredItems, { limit: 10 })
`,
},
]
: [
{
fileName: 'app/computed.js',
code: `
export const filteredItems = filterNameBy => state =>
state.items.filter(item => item.name === filterNameBy)
`,
},
{
fileName: 'app/state.js',
code: `
import { compute } from 'overmind'
import * as computed from './computed'
export const items = []
export const filteredItems = compute(computed.filteredItems, { limit: 10 })
`,
},
]