forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
58 lines (45 loc) · 1.27 KB
/
index.ts
File metadata and controls
58 lines (45 loc) · 1.27 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
51
52
53
54
55
56
57
58
import App, {
TAction,
TApp,
TContext,
TDerive,
TMutate,
TReaction,
} from 'overmind'
import createConnect, { TConnect } from 'overmind-react'
import * as actions from './actions'
import * as context from './context'
import * as state from './state'
const config = {
context,
actions,
state,
}
const app = new App(config, {
devtools: false,
})
export type Connect = TConnect<typeof app>
export const connect = createConnect(app)
export default app
// === copy/paste
type IApp = TApp<typeof config>
export type Action<Value = void, ReturnValue = any> = TAction<
IApp,
Value,
ReturnValue
>
export type Mutate<Value = any> = TMutate<IApp, Value>
export type Context<Value> = TContext<IApp, Value>
// Operations
export namespace Operation {
export type Map<Value, ReturnValue = Value> = (
ctx: Context<Value>
) => ReturnValue
export type Filter<Value = any> = (ctx: Context<Value>) => boolean
export type When<Value = any> = (ctx: Context<Value>) => boolean
export type Run<Value = any> = (ctx: Context<Value>) => void
export type Fork<Value = any> = (ctx: Context<Value>) => string
export type Attempt<Value, ReturnValue> = (ctx: Context<Value>) => ReturnValue
}
export type Derive<Value> = TDerive<IApp, Value>
export type Reaction = TReaction<IApp>