forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperations.ts
More file actions
32 lines (25 loc) · 929 Bytes
/
operations.ts
File metadata and controls
32 lines (25 loc) · 929 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
import { Operation } from './'
import { Message } from './types'
export const isPortExistsMessage: Operation.When<Message> = ({
value: message,
}) => message.messages[0].type === 'PORT_EXISTS'
export const confirm: (text: string) => Operation.Filter = (text) => ({
utils,
}) => utils.confirmDialog(text)
export const getCurrentPortFromStorage: Operation.Map<any, Promise<string>> = ({
storage,
}) => storage.get<string>('currentPort')
export const getNewPortFromState: Operation.Map<any, string> = ({ state }) =>
state.newPortValue
export const toNumber: Operation.Map<string, string> = ({ value }) =>
String(Number(value))
export const connectCurrentPort: (
action: (message: any) => void
) => Operation.Run = (action) => ({ state, connector }) => {
connector.connect(
state.port,
action
)
}
export const isNotExpandingAllActions: Operation.Filter = ({ state }) =>
!state.expandAllActionDetails