Skip to content

Commit 3919d49

Browse files
refactor(overmind-devtools): refactor to new typing
1 parent 23fa693 commit 3919d49

File tree

4 files changed

+43
-45
lines changed

4 files changed

+43
-45
lines changed

packages/node_modules/overmind-devtools/src/app/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Action } from './'
22
import * as mutations from './mutations'
33
import * as operations from './operations'
4-
import { GroupedComponent, Message, Tab } from './types'
4+
import { Message, Tab } from './types'
55

66
const handleClientMessages: Action<Message> = (action) =>
77
action
Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import App, {
1+
import Overmind, {
22
TAction,
33
TApp,
44
TContext,
@@ -18,41 +18,42 @@ const config = {
1818
state,
1919
}
2020

21-
const app = new App(config, {
22-
devtools: false,
23-
})
24-
25-
export type Connect = TConnect<typeof app>
26-
27-
export const connect = createConnect(app)
21+
type App = TApp<typeof config>
2822

29-
export default app
30-
31-
// === copy/paste
32-
33-
type IApp = TApp<typeof config>
3423
export type Action<Value = void, ReturnValue = any> = TAction<
35-
IApp,
24+
App,
3625
Value,
3726
ReturnValue
3827
>
3928

40-
export type Mutate<Value = any> = TMutate<IApp, Value>
29+
export type Mutate<Value = any> = TMutate<App, Value>
4130

42-
export type Context<Value> = TContext<IApp, Value>
31+
export type Context<Value> = TContext<App, Value>
4332

44-
// Operations
45-
export namespace Operation {
46-
export type Map<Value, ReturnValue = Value> = (
47-
ctx: Context<Value>
48-
) => ReturnValue
49-
export type Filter<Value = any> = (ctx: Context<Value>) => boolean
50-
export type When<Value = any> = (ctx: Context<Value>) => boolean
51-
export type Run<Value = any> = (ctx: Context<Value>) => void
52-
export type Fork<Value = any> = (ctx: Context<Value>) => string
53-
export type Attempt<Value, ReturnValue> = (ctx: Context<Value>) => ReturnValue
54-
}
33+
export type Map<Value, ReturnValue = Value> = (
34+
ctx: Context<Value>
35+
) => ReturnValue
36+
37+
export type Filter<Value = any> = (ctx: Context<Value>) => boolean
38+
39+
export type When<Value = any> = (ctx: Context<Value>) => boolean
5540

56-
export type Derive<Value> = TDerive<IApp, Value>
41+
export type Run<Value = any> = (ctx: Context<Value>) => void
5742

58-
export type Reaction = TReaction<IApp>
43+
export type Fork<Value = any> = (ctx: Context<Value>) => string
44+
45+
export type Attempt<Value, ReturnValue> = (ctx: Context<Value>) => ReturnValue
46+
47+
export type Derive<Value> = TDerive<App, Value>
48+
49+
export type Reaction = TReaction<App>
50+
51+
const app = new Overmind(config, {
52+
devtools: false,
53+
})
54+
55+
export type Connect = TConnect<typeof app>
56+
57+
export const connect = createConnect(app)
58+
59+
export default app

packages/node_modules/overmind-devtools/src/app/mutations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
ActionGroupItem,
44
ActionItem,
55
ActionsListItemType,
6-
GroupedComponent,
76
Message,
87
Tab,
98
} from './types'
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
import { Operation } from './'
1+
import { When, Filter, Map, Run } from './'
22
import { Message } from './types'
33

4-
export const isPortExistsMessage: Operation.When<Message> = ({
5-
value: message,
6-
}) => message.messages[0].type === 'PORT_EXISTS'
4+
export const isPortExistsMessage: When<Message> = ({ value: message }) =>
5+
message.messages[0].type === 'PORT_EXISTS'
76

8-
export const confirm: (text: string) => Operation.Filter = (text) => ({
9-
utils,
10-
}) => utils.confirmDialog(text)
7+
export const confirm: (text: string) => Filter = (text) => ({ utils }) =>
8+
utils.confirmDialog(text)
119

12-
export const getCurrentPortFromStorage: Operation.Map<any, Promise<string>> = ({
10+
export const getCurrentPortFromStorage: Map<any, Promise<string>> = ({
1311
storage,
1412
}) => storage.get<string>('currentPort')
1513

16-
export const getNewPortFromState: Operation.Map<any, string> = ({ state }) =>
14+
export const getNewPortFromState: Map<any, string> = ({ state }) =>
1715
state.newPortValue
1816

19-
export const toNumber: Operation.Map<string, string> = ({ value }) =>
17+
export const toNumber: Map<string, string> = ({ value }) =>
2018
String(Number(value))
2119

22-
export const connectCurrentPort: (
23-
action: (message: any) => void
24-
) => Operation.Run = (action) => ({ state, connector }) => {
20+
export const connectCurrentPort: (action: (message: any) => void) => Run = (
21+
action
22+
) => ({ state, connector }) => {
2523
connector.connect(
2624
state.port,
2725
action
2826
)
2927
}
3028

31-
export const isNotExpandingAllActions: Operation.Filter = ({ state }) =>
29+
export const isNotExpandingAllActions: Filter = ({ state }) =>
3230
!state.expandAllActionDetails

0 commit comments

Comments
 (0)