Skip to content

Commit 5c0cdb6

Browse files
committed
chore: bump dependencies
1 parent b1b3d24 commit 5c0cdb6

File tree

4 files changed

+1128
-932
lines changed

4 files changed

+1128
-932
lines changed

package.json

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,43 +62,44 @@
6262
},
6363
"devDependencies": {
6464
"@asuka/di": "^0.1.5",
65-
"@types/jest": "^24.0.11",
66-
"@types/lodash": "^4.14.123",
67-
"@types/node": "^12.0.0",
68-
"@types/react": "^16.8.10",
69-
"@types/react-dom": "^16.8.3",
70-
"@types/react-test-renderer": "^16.8.1",
65+
"@types/jest": "^24.0.16",
66+
"@types/lodash": "^4.14.136",
67+
"@types/node": "^12.6.9",
68+
"@types/react": "^16.8.24",
69+
"@types/react-dom": "^16.8.5",
70+
"@types/react-test-renderer": "^16.8.3",
7171
"@types/shallowequal": "^1.1.1",
72-
"@typescript-eslint/eslint-plugin": "^1.7.0",
73-
"codecov": "^3.2.0",
74-
"eslint": "5.3.0",
75-
"eslint-config-prettier": "^5.0.0",
76-
"eslint-plugin-react": "^7.12.4",
77-
"husky": "^3.0.0",
78-
"immer": "^3.1.2",
79-
"jest": "^24.5.0",
80-
"lint-staged": "^9.1.0",
81-
"lodash": "^4.17.11",
72+
"@typescript-eslint/eslint-plugin": "^1.13.0",
73+
"@typescript-eslint/parser": "^1.13.0",
74+
"codecov": "^3.5.0",
75+
"eslint": "6.1.0",
76+
"eslint-config-prettier": "^6.0.0",
77+
"eslint-plugin-react": "^7.14.3",
78+
"husky": "^3.0.2",
79+
"immer": "^3.2.0",
80+
"jest": "^24.8.0",
81+
"lint-staged": "^9.2.1",
82+
"lodash": "^4.17.15",
8283
"madge": "^3.4.4",
8384
"npm-run-all": "^4.1.5",
8485
"parcel": "^1.12.3",
85-
"prettier": "^1.16.4",
86+
"prettier": "^1.18.2",
8687
"react": "^16.8.6",
8788
"react-dom": "^16.8.6",
8889
"react-test-renderer": "^16.8.6",
8990
"reflect-metadata": "^0.1.13",
90-
"rxjs": "^6.4.0",
91+
"rxjs": "^6.5.2",
9192
"shx": "^0.3.2",
92-
"ts-jest": "^24.0.1",
93-
"tslib": "^1.9.3",
94-
"typescript": "^3.4.4"
93+
"ts-jest": "^24.0.2",
94+
"tslib": "^1.10.0",
95+
"typescript": "^3.5.3"
9596
},
9697
"peerDependencies": {
97-
"@asuka/di": "^0.1.3",
98-
"immer": "^3.1.2",
99-
"lodash": "^4.17.11",
98+
"@asuka/di": "^0.1.5",
99+
"immer": "^3.2.0",
100+
"lodash": "^4.17.15",
100101
"react": "^16.8.6",
101102
"reflect-metadata": "^0.1.13",
102-
"rxjs": "^6.4.0"
103+
"rxjs": "^6.5.2"
103104
}
104105
}

src/core/decorators/action-related.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { allActionSymbols, ActionSymbols } from '../symbols'
2+
import { Ayanami } from '../ayanami'
3+
import { ConstructorOf } from '../types'
24

35
export function createActionDecorator(symbols: ActionSymbols) {
46
return () => ({ constructor }: any, propertyKey: string) => {
@@ -11,13 +13,19 @@ function addActionName(symbols: ActionSymbols, constructor: Function, actionName
1113
Reflect.defineMetadata(symbols.decorator, [...decoratedActionNames, actionName], constructor)
1214
}
1315

14-
export function getActionNames(symbols: ActionSymbols, constructor: Function): string[] {
16+
export function getActionNames<T extends Ayanami<any>>(
17+
symbols: ActionSymbols,
18+
constructor: ConstructorOf<T>,
19+
): (keyof T)[] {
1520
return Reflect.getMetadata(symbols.decorator, constructor) || []
1621
}
1722

18-
export function getAllActionNames(instance: { constructor: Function }) {
19-
return allActionSymbols.reduce<string[]>(
20-
(result, symbols) => [...result, ...getActionNames(symbols, instance.constructor)],
23+
export function getAllActionNames<T extends Ayanami<any>>(instance: T) {
24+
return allActionSymbols.reduce<(keyof T)[]>(
25+
(result, symbols) => [
26+
...result,
27+
...getActionNames(symbols, instance.constructor as ConstructorOf<T>),
28+
],
2129
[],
2230
)
2331
}
Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import { Subject } from 'rxjs'
2-
import { pick, mapValues } from 'lodash'
32

43
import {
54
OriginalDefineActions,
65
OriginalEffectActions,
76
OriginalReducerActions,
87
OriginalImmerReducerActions,
8+
ConstructorOf,
99
} from '../types'
1010
import { Ayanami } from '../ayanami'
1111
import { getActionNames } from '../decorators'
1212
import { effectSymbols, reducerSymbols, immerReducerSymbols, defineActionSymbols } from '../symbols'
1313

1414
const getOriginalFunctionNames = (ayanami: Ayanami<any>) => ({
15-
effects: getActionNames(effectSymbols, ayanami.constructor),
16-
reducers: getActionNames(reducerSymbols, ayanami.constructor),
17-
defineActions: getActionNames(defineActionSymbols, ayanami.constructor),
18-
immerReducers: getActionNames(immerReducerSymbols, ayanami.constructor),
15+
effects: getActionNames(effectSymbols, ayanami.constructor as ConstructorOf<Ayanami<any>>),
16+
reducers: getActionNames(reducerSymbols, ayanami.constructor as ConstructorOf<Ayanami<any>>),
17+
defineActions: getActionNames(defineActionSymbols, ayanami.constructor as ConstructorOf<
18+
Ayanami<any>
19+
>),
20+
immerReducers: getActionNames(immerReducerSymbols, ayanami.constructor as ConstructorOf<
21+
Ayanami<any>
22+
>),
1923
})
2024

2125
const transformDefineActions = (actionNames: string[]): OriginalDefineActions => {
@@ -37,15 +41,18 @@ export const getOriginalFunctions = (ayanami: Ayanami<any>) => {
3741
const { effects, reducers, immerReducers, defineActions } = getOriginalFunctionNames(ayanami)
3842

3943
return {
40-
effects: mapValues(pick(ayanami, effects), (func: Function) =>
41-
func.bind(ayanami),
42-
) as OriginalEffectActions<any>,
43-
reducers: mapValues(pick(ayanami, reducers), (func: Function) =>
44-
func.bind(ayanami),
45-
) as OriginalReducerActions<any>,
46-
immerReducers: mapValues(pick(ayanami, immerReducers), (func: Function) =>
47-
func.bind(ayanami),
48-
) as OriginalImmerReducerActions<any>,
44+
effects: effects.reduce<OriginalEffectActions<any>>((acc, method) => {
45+
acc[method] = ayanami[method].bind(ayanami)
46+
return acc
47+
}, {}),
48+
reducers: reducers.reduce<OriginalReducerActions<any>>((acc, method) => {
49+
acc[method] = ayanami[method].bind(ayanami)
50+
return acc
51+
}, {}),
52+
immerReducers: immerReducers.reduce<OriginalImmerReducerActions<any>>((acc, method) => {
53+
acc[method] = ayanami[method].bind(ayanami)
54+
return acc
55+
}, {}),
4956
defineActions: transformDefineActions(defineActions),
5057
}
5158
}

0 commit comments

Comments
 (0)