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
33 lines (24 loc) · 982 Bytes
/
operations.ts
File metadata and controls
33 lines (24 loc) · 982 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
import { Map, Filter, Do } from '../app'
import { Apps } from './state'
export const getAppsFromStorage: Map<any, Promise<Apps>> = ({ storage }) =>
storage.get<Apps>('apps')
export const confirm: (text: string) => Filter = (text) => ({ utils }) =>
utils.confirmDialog(text)
export const getCurrentPortFromStorage: Map<any, Promise<string>> = ({
storage,
}) => storage.get<string>('currentPort')
export const getNewPortFromState: Map<any, string> = ({ state }) =>
state.newPortValue
export const storeApps: Do = ({ storage, state }) =>
storage.set('apps', state.apps)
export const toNumber: Map<string, string> = (_, value) => String(Number(value))
export const connectCurrentPort: (action: (message: any) => void) => Do = (
action
) => ({ state, connector }) => {
if (!state.currentPort) {
return
}
connector.addPort(state.currentPort, action)
}
export const removeCurrentPort: Do = ({ state, connector }) =>
connector.removePort(state.currentPort)