forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathderive.ts
More file actions
40 lines (36 loc) · 700 Bytes
/
derive.ts
File metadata and controls
40 lines (36 loc) · 700 Bytes
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
export default (ts) =>
ts
? [
{
fileName: 'overmind/state.ts',
code: `
import { Derive } from 'overmind'
export type Item = {
title: string
completed: boolean
}
export type State = {
items: Item[]
completedItems: Derive<State, Item[]>
}
export const state: State = {
items: [],
completedItems: (state, rootState) =>
state.items.filter(item => item.completed)
}
`,
},
]
: [
{
fileName: 'overmind/state.js',
code: `
import * as derived from './derived'
export default {
items: [],
completedItems: (state, rootState) =>
state.items.filter(item => item.completed)
}
`,
},
]