diff options
author | 2022-06-22 00:32:18 +0200 | |
---|---|---|
committer | 2022-06-21 22:32:18 +0000 | |
commit | 73ba955e344c8ccedd43235495ef8b72b5a2b6fd (patch) | |
tree | 03766ab32fefe7e83026a14393527f1dcbaed849 /src/actions/lib | |
parent | docs: add cino as a contributor for infra [skip ci] (#330) (diff) | |
download | ferdium-app-73ba955e344c8ccedd43235495ef8b72b5a2b6fd.tar.gz ferdium-app-73ba955e344c8ccedd43235495ef8b72b5a2b6fd.tar.zst ferdium-app-73ba955e344c8ccedd43235495ef8b72b5a2b6fd.zip |
chore: Transform AppStore.js into Typescript (#329)
* turn actions into typescript
* correct tsconfig
* added TypedStore
Diffstat (limited to 'src/actions/lib')
-rw-r--r-- | src/actions/lib/actions.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/actions/lib/actions.ts b/src/actions/lib/actions.ts index 412a0d895..378cef574 100644 --- a/src/actions/lib/actions.ts +++ b/src/actions/lib/actions.ts | |||
@@ -1,4 +1,27 @@ | |||
1 | export const createActionsFromDefinitions = (actionDefinitions, validate) => { | 1 | import PropTypes from 'prop-types'; |
2 | |||
3 | export interface ActionDefinitions { | ||
4 | [key: string]: { | ||
5 | [key: string]: PropTypes.InferType<any>; | ||
6 | }; | ||
7 | } | ||
8 | |||
9 | export interface Actions { | ||
10 | [key: string]: { | ||
11 | [key: string]: { | ||
12 | (...args: any[]): void; | ||
13 | listeners: Array<Function>; | ||
14 | notify: (params: any) => void; | ||
15 | listen: (listener: (params: any) => void) => void; | ||
16 | off: (listener: (params: any) => void) => void; | ||
17 | }; | ||
18 | }; | ||
19 | } | ||
20 | |||
21 | export const createActionsFromDefinitions = ( | ||
22 | actionDefinitions: ActionDefinitions, | ||
23 | validate: any, | ||
24 | ) => { | ||
2 | const actions = {}; | 25 | const actions = {}; |
3 | // eslint-disable-next-line unicorn/no-array-for-each | 26 | // eslint-disable-next-line unicorn/no-array-for-each |
4 | Object.keys(actionDefinitions).forEach(actionName => { | 27 | Object.keys(actionDefinitions).forEach(actionName => { |