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
39 lines (29 loc) · 1.14 KB
/
operations.ts
File metadata and controls
39 lines (29 loc) · 1.14 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
import { Operation } from 'overmind'
import { Apps } from './types'
export const getAppsFromStorage: Operation.Map<any, Promise<Apps>> = ({
storage,
}) => storage.get<Apps>('apps')
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 storeApps: Operation.Do = ({ storage, state }) =>
storage.set('apps', state.apps)
export const toNumber: Operation.Map<string, string> = (_, value) =>
String(Number(value))
export const connectCurrentPort: (
action: (message: any) => void
) => Operation.Do = (action) => ({ state, connector }) => {
if (!state.currentPort) {
return
}
connector.addPort(state.currentPort, action)
}
export const removeCurrentPort: Operation.Do = ({ state, connector }) =>
connector.removePort(state.currentPort)
export const isNotExpandingAllActions: Operation.Filter = ({ state }) =>
!state.expandAllActionDetails