isomorfeus-redux 4.0.23 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +27 -0
- data/lib/isomorfeus/core_ext/kernel.rb +1 -1
- data/lib/isomorfeus/execution_environment.rb +17 -10
- data/lib/isomorfeus/{redux_config.rb → redux/config.rb} +0 -0
- data/lib/isomorfeus/redux/imports.rb +17 -0
- data/lib/isomorfeus-redux.rb +7 -4
- data/lib/redux/version.rb +1 -1
- data/node_modules/.package-lock.json +31 -0
- data/node_modules/@babel/runtime/LICENSE +22 -0
- data/node_modules/@babel/runtime/README.md +19 -0
- data/node_modules/@babel/runtime/helpers/AsyncGenerator.js +99 -0
- data/node_modules/@babel/runtime/helpers/AwaitValue.js +6 -0
- data/node_modules/@babel/runtime/helpers/applyDecoratedDescriptor.js +31 -0
- data/node_modules/@babel/runtime/helpers/arrayLikeToArray.js +12 -0
- data/node_modules/@babel/runtime/helpers/arrayWithHoles.js +6 -0
- data/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js +8 -0
- data/node_modules/@babel/runtime/helpers/assertThisInitialized.js +10 -0
- data/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js +57 -0
- data/node_modules/@babel/runtime/helpers/asyncIterator.js +16 -0
- data/node_modules/@babel/runtime/helpers/asyncToGenerator.js +38 -0
- data/node_modules/@babel/runtime/helpers/awaitAsyncGenerator.js +8 -0
- data/node_modules/@babel/runtime/helpers/checkPrivateRedeclaration.js +8 -0
- data/node_modules/@babel/runtime/helpers/classApplyDescriptorDestructureSet.js +23 -0
- data/node_modules/@babel/runtime/helpers/classApplyDescriptorGet.js +10 -0
- data/node_modules/@babel/runtime/helpers/classApplyDescriptorSet.js +14 -0
- data/node_modules/@babel/runtime/helpers/classCallCheck.js +8 -0
- data/node_modules/@babel/runtime/helpers/classCheckPrivateStaticAccess.js +8 -0
- data/node_modules/@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +8 -0
- data/node_modules/@babel/runtime/helpers/classExtractFieldDescriptor.js +10 -0
- data/node_modules/@babel/runtime/helpers/classNameTDZError.js +6 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js +11 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js +11 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldInitSpec.js +9 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js +10 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldLooseKey.js +8 -0
- data/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js +12 -0
- data/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js +10 -0
- data/node_modules/@babel/runtime/helpers/classPrivateMethodInitSpec.js +9 -0
- data/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js +6 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateFieldDestructureSet.js +14 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js +14 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js +15 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateMethodGet.js +9 -0
- data/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js +6 -0
- data/node_modules/@babel/runtime/helpers/construct.js +26 -0
- data/node_modules/@babel/runtime/helpers/createClass.js +18 -0
- data/node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js +61 -0
- data/node_modules/@babel/runtime/helpers/createForOfIteratorHelperLoose.js +25 -0
- data/node_modules/@babel/runtime/helpers/createSuper.js +25 -0
- data/node_modules/@babel/runtime/helpers/decorate.js +401 -0
- data/node_modules/@babel/runtime/helpers/defaults.js +17 -0
- data/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js +25 -0
- data/node_modules/@babel/runtime/helpers/defineProperty.js +17 -0
- data/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js +95 -0
- data/node_modules/@babel/runtime/helpers/esm/AwaitValue.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js +28 -0
- data/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +4 -0
- data/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js +54 -0
- data/node_modules/@babel/runtime/helpers/esm/asyncIterator.js +13 -0
- data/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js +35 -0
- data/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js +4 -0
- data/node_modules/@babel/runtime/helpers/esm/checkPrivateRedeclaration.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorDestructureSet.js +20 -0
- data/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js +11 -0
- data/node_modules/@babel/runtime/helpers/esm/classCallCheck.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticAccess.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classNameTDZError.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldInitSpec.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseBase.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseKey.js +4 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateMethodInitSpec.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldDestructureSet.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodGet.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/construct.js +18 -0
- data/node_modules/@babel/runtime/helpers/esm/createClass.js +15 -0
- data/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js +57 -0
- data/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelperLoose.js +21 -0
- data/node_modules/@babel/runtime/helpers/esm/createSuper.js +19 -0
- data/node_modules/@babel/runtime/helpers/esm/decorate.js +396 -0
- data/node_modules/@babel/runtime/helpers/esm/defaults.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js +22 -0
- data/node_modules/@babel/runtime/helpers/esm/defineProperty.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/extends.js +17 -0
- data/node_modules/@babel/runtime/helpers/esm/get.js +20 -0
- data/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/inherits.js +15 -0
- data/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/instanceof.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/interopRequireDefault.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +51 -0
- data/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +12 -0
- data/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +29 -0
- data/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimitLoose.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/jsx.js +46 -0
- data/node_modules/@babel/runtime/helpers/esm/maybeArrayLike.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/newArrowCheck.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/objectSpread.js +19 -0
- data/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +39 -0
- data/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +19 -0
- data/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +14 -0
- data/node_modules/@babel/runtime/helpers/esm/package.json +3 -0
- data/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js +11 -0
- data/node_modules/@babel/runtime/helpers/esm/readOnlyError.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/set.js +51 -0
- data/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/skipFirstGeneratorNext.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/slicedToArray.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/slicedToArrayLoose.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/superPropBase.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js +11 -0
- data/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteralLoose.js +8 -0
- data/node_modules/@babel/runtime/helpers/esm/tdz.js +3 -0
- data/node_modules/@babel/runtime/helpers/esm/temporalRef.js +5 -0
- data/node_modules/@babel/runtime/helpers/esm/temporalUndefined.js +1 -0
- data/node_modules/@babel/runtime/helpers/esm/toArray.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +7 -0
- data/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +13 -0
- data/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/typeof.js +15 -0
- data/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +9 -0
- data/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js +6 -0
- data/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +37 -0
- data/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js +65 -0
- data/node_modules/@babel/runtime/helpers/esm/writeOnlyError.js +3 -0
- data/node_modules/@babel/runtime/helpers/extends.js +21 -0
- data/node_modules/@babel/runtime/helpers/get.js +27 -0
- data/node_modules/@babel/runtime/helpers/getPrototypeOf.js +10 -0
- data/node_modules/@babel/runtime/helpers/inherits.js +19 -0
- data/node_modules/@babel/runtime/helpers/inheritsLoose.js +10 -0
- data/node_modules/@babel/runtime/helpers/initializerDefineProperty.js +12 -0
- data/node_modules/@babel/runtime/helpers/initializerWarningHelper.js +6 -0
- data/node_modules/@babel/runtime/helpers/instanceof.js +10 -0
- data/node_modules/@babel/runtime/helpers/interopRequireDefault.js +8 -0
- data/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +54 -0
- data/node_modules/@babel/runtime/helpers/isNativeFunction.js +6 -0
- data/node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js +15 -0
- data/node_modules/@babel/runtime/helpers/iterableToArray.js +6 -0
- data/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js +32 -0
- data/node_modules/@babel/runtime/helpers/iterableToArrayLimitLoose.js +17 -0
- data/node_modules/@babel/runtime/helpers/jsx.js +50 -0
- data/node_modules/@babel/runtime/helpers/maybeArrayLike.js +13 -0
- data/node_modules/@babel/runtime/helpers/newArrowCheck.js +8 -0
- data/node_modules/@babel/runtime/helpers/nonIterableRest.js +6 -0
- data/node_modules/@babel/runtime/helpers/nonIterableSpread.js +6 -0
- data/node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js +6 -0
- data/node_modules/@babel/runtime/helpers/objectSpread.js +23 -0
- data/node_modules/@babel/runtime/helpers/objectSpread2.js +42 -0
- data/node_modules/@babel/runtime/helpers/objectWithoutProperties.js +23 -0
- data/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js +17 -0
- data/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js +16 -0
- data/node_modules/@babel/runtime/helpers/readOnlyError.js +6 -0
- data/node_modules/@babel/runtime/helpers/set.js +55 -0
- data/node_modules/@babel/runtime/helpers/setPrototypeOf.js +12 -0
- data/node_modules/@babel/runtime/helpers/skipFirstGeneratorNext.js +10 -0
- data/node_modules/@babel/runtime/helpers/slicedToArray.js +14 -0
- data/node_modules/@babel/runtime/helpers/slicedToArrayLoose.js +14 -0
- data/node_modules/@babel/runtime/helpers/superPropBase.js +13 -0
- data/node_modules/@babel/runtime/helpers/taggedTemplateLiteral.js +14 -0
- data/node_modules/@babel/runtime/helpers/taggedTemplateLiteralLoose.js +11 -0
- data/node_modules/@babel/runtime/helpers/tdz.js +6 -0
- data/node_modules/@babel/runtime/helpers/temporalRef.js +10 -0
- data/node_modules/@babel/runtime/helpers/temporalUndefined.js +4 -0
- data/node_modules/@babel/runtime/helpers/toArray.js +14 -0
- data/node_modules/@babel/runtime/helpers/toConsumableArray.js +14 -0
- data/node_modules/@babel/runtime/helpers/toPrimitive.js +17 -0
- data/node_modules/@babel/runtime/helpers/toPropertyKey.js +11 -0
- data/node_modules/@babel/runtime/helpers/typeof.js +22 -0
- data/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js +13 -0
- data/node_modules/@babel/runtime/helpers/wrapAsyncGenerator.js +10 -0
- data/node_modules/@babel/runtime/helpers/wrapNativeSuper.js +45 -0
- data/node_modules/@babel/runtime/helpers/wrapRegExp.js +72 -0
- data/node_modules/@babel/runtime/helpers/writeOnlyError.js +6 -0
- data/node_modules/@babel/runtime/package.json +848 -0
- data/node_modules/@babel/runtime/regenerator/index.js +1 -0
- data/node_modules/redux/LICENSE.md +21 -0
- data/node_modules/redux/README.md +322 -0
- data/node_modules/redux/dist/redux.js +735 -0
- data/node_modules/redux/dist/redux.min.js +1 -0
- data/node_modules/redux/es/redux.js +684 -0
- data/node_modules/redux/es/redux.mjs +1 -0
- data/node_modules/redux/index.d.ts +676 -0
- data/node_modules/redux/lib/redux.js +697 -0
- data/node_modules/redux/package.json +108 -0
- data/node_modules/redux/src/applyMiddleware.js +41 -0
- data/node_modules/redux/src/bindActionCreators.js +52 -0
- data/node_modules/redux/src/combineReducers.js +175 -0
- data/node_modules/redux/src/compose.js +22 -0
- data/node_modules/redux/src/createStore.js +315 -0
- data/node_modules/redux/src/index.js +36 -0
- data/node_modules/redux/src/utils/actionTypes.js +17 -0
- data/node_modules/redux/src/utils/formatProdErrorMessage.js +15 -0
- data/node_modules/redux/src/utils/isPlainObject.js +14 -0
- data/node_modules/redux/src/utils/kindOf.js +70 -0
- data/node_modules/redux/src/utils/symbol-observable.js +3 -0
- data/node_modules/redux/src/utils/warning.js +19 -0
- data/node_modules/regenerator-runtime/LICENSE +21 -0
- data/node_modules/regenerator-runtime/README.md +31 -0
- data/node_modules/regenerator-runtime/package.json +19 -0
- data/node_modules/regenerator-runtime/path.js +11 -0
- data/node_modules/regenerator-runtime/runtime.js +754 -0
- data/package.json +6 -0
- metadata +240 -10
- data/README.md +0 -223
@@ -0,0 +1,108 @@
|
|
1
|
+
{
|
2
|
+
"name": "redux",
|
3
|
+
"version": "4.1.1",
|
4
|
+
"description": "Predictable state container for JavaScript apps",
|
5
|
+
"license": "MIT",
|
6
|
+
"homepage": "http://redux.js.org",
|
7
|
+
"repository": "github:reduxjs/redux",
|
8
|
+
"bugs": "https://github.com/reduxjs/redux/issues",
|
9
|
+
"keywords": [
|
10
|
+
"redux",
|
11
|
+
"reducer",
|
12
|
+
"state",
|
13
|
+
"predictable",
|
14
|
+
"functional",
|
15
|
+
"immutable",
|
16
|
+
"hot",
|
17
|
+
"live",
|
18
|
+
"replay",
|
19
|
+
"flux",
|
20
|
+
"elm"
|
21
|
+
],
|
22
|
+
"authors": [
|
23
|
+
"Dan Abramov <dan.abramov@me.com> (https://github.com/gaearon)",
|
24
|
+
"Andrew Clark <acdlite@me.com> (https://github.com/acdlite)"
|
25
|
+
],
|
26
|
+
"main": "lib/redux.js",
|
27
|
+
"unpkg": "dist/redux.js",
|
28
|
+
"module": "es/redux.js",
|
29
|
+
"typings": "./index.d.ts",
|
30
|
+
"files": [
|
31
|
+
"dist",
|
32
|
+
"lib",
|
33
|
+
"es",
|
34
|
+
"src",
|
35
|
+
"index.d.ts"
|
36
|
+
],
|
37
|
+
"scripts": {
|
38
|
+
"clean": "rimraf lib dist es coverage",
|
39
|
+
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
|
40
|
+
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
|
41
|
+
"lint": "eslint src test",
|
42
|
+
"test": "jest",
|
43
|
+
"test:watch": "npm test -- --watch",
|
44
|
+
"test:cov": "npm test -- --coverage",
|
45
|
+
"build": "rollup -c",
|
46
|
+
"pretest": "npm run build",
|
47
|
+
"prepublishOnly": "npm run clean && npm run format:check && npm run lint && npm test",
|
48
|
+
"examples:lint": "eslint examples",
|
49
|
+
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
|
50
|
+
},
|
51
|
+
"dependencies": {
|
52
|
+
"@babel/runtime": "^7.9.2"
|
53
|
+
},
|
54
|
+
"devDependencies": {
|
55
|
+
"@babel/cli": "^7.8.4",
|
56
|
+
"@babel/core": "^7.9.0",
|
57
|
+
"@babel/node": "^7.8.7",
|
58
|
+
"@babel/plugin-external-helpers": "^7.8.3",
|
59
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
|
60
|
+
"@babel/plugin-transform-runtime": "^7.9.0",
|
61
|
+
"@babel/preset-env": "^7.9.5",
|
62
|
+
"@babel/preset-flow": "^7.9.0",
|
63
|
+
"@babel/preset-typescript": "^7.9.0",
|
64
|
+
"@babel/register": "^7.9.0",
|
65
|
+
"@rollup/plugin-babel": "^5.3.0",
|
66
|
+
"@rollup/plugin-node-resolve": "^7.1.3",
|
67
|
+
"@rollup/plugin-replace": "^2.3.2",
|
68
|
+
"@types/jest": "^25.2.1",
|
69
|
+
"@types/node": "^13.13.4",
|
70
|
+
"@typescript-eslint/eslint-plugin": "^2.29.0",
|
71
|
+
"@typescript-eslint/parser": "^2.29.0",
|
72
|
+
"babel-eslint": "^10.1.0",
|
73
|
+
"babel-jest": "^25.4.0",
|
74
|
+
"cross-env": "^7.0.2",
|
75
|
+
"eslint": "^6.8.0",
|
76
|
+
"eslint-config-react-app": "^5.2.1",
|
77
|
+
"eslint-import-resolver-typescript": "^2.0.0",
|
78
|
+
"eslint-plugin-flowtype": "^4.7.0",
|
79
|
+
"eslint-plugin-import": "^2.20.2",
|
80
|
+
"eslint-plugin-jsx-a11y": "^6.2.3",
|
81
|
+
"eslint-plugin-react": "^7.19.0",
|
82
|
+
"eslint-plugin-react-hooks": "^3.0.0",
|
83
|
+
"glob": "^7.1.6",
|
84
|
+
"jest": "^25.4.0",
|
85
|
+
"prettier": "^2.0.5",
|
86
|
+
"rimraf": "^3.0.2",
|
87
|
+
"rollup": "^2.7.2",
|
88
|
+
"rollup-plugin-terser": "^5.3.0",
|
89
|
+
"rollup-plugin-typescript2": "^0.27.0",
|
90
|
+
"rxjs": "^6.5.5",
|
91
|
+
"typescript": "^3.8.3",
|
92
|
+
"typings-tester": "^0.3.2"
|
93
|
+
},
|
94
|
+
"npmName": "redux",
|
95
|
+
"npmFileMap": [
|
96
|
+
{
|
97
|
+
"basePath": "/dist/",
|
98
|
+
"files": [
|
99
|
+
"*.js"
|
100
|
+
]
|
101
|
+
}
|
102
|
+
],
|
103
|
+
"jest": {
|
104
|
+
"testRegex": "(/test/.*\\.spec\\.[tj]s)$",
|
105
|
+
"coverageProvider": "v8"
|
106
|
+
},
|
107
|
+
"sideEffects": false
|
108
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import compose from './compose'
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Creates a store enhancer that applies middleware to the dispatch method
|
5
|
+
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
6
|
+
* asynchronous actions in a concise manner, or logging every action payload.
|
7
|
+
*
|
8
|
+
* See `redux-thunk` package as an example of the Redux middleware.
|
9
|
+
*
|
10
|
+
* Because middleware is potentially asynchronous, this should be the first
|
11
|
+
* store enhancer in the composition chain.
|
12
|
+
*
|
13
|
+
* Note that each middleware will be given the `dispatch` and `getState` functions
|
14
|
+
* as named arguments.
|
15
|
+
*
|
16
|
+
* @param {...Function} middlewares The middleware chain to be applied.
|
17
|
+
* @returns {Function} A store enhancer applying the middleware.
|
18
|
+
*/
|
19
|
+
export default function applyMiddleware(...middlewares) {
|
20
|
+
return (createStore) => (...args) => {
|
21
|
+
const store = createStore(...args)
|
22
|
+
let dispatch = () => {
|
23
|
+
throw new Error(
|
24
|
+
'Dispatching while constructing your middleware is not allowed. ' +
|
25
|
+
'Other middleware would not be applied to this dispatch.'
|
26
|
+
)
|
27
|
+
}
|
28
|
+
|
29
|
+
const middlewareAPI = {
|
30
|
+
getState: store.getState,
|
31
|
+
dispatch: (...args) => dispatch(...args),
|
32
|
+
}
|
33
|
+
const chain = middlewares.map((middleware) => middleware(middlewareAPI))
|
34
|
+
dispatch = compose(...chain)(store.dispatch)
|
35
|
+
|
36
|
+
return {
|
37
|
+
...store,
|
38
|
+
dispatch,
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { kindOf } from './utils/kindOf'
|
2
|
+
|
3
|
+
function bindActionCreator(actionCreator, dispatch) {
|
4
|
+
return function () {
|
5
|
+
return dispatch(actionCreator.apply(this, arguments))
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Turns an object whose values are action creators, into an object with the
|
11
|
+
* same keys, but with every function wrapped into a `dispatch` call so they
|
12
|
+
* may be invoked directly. This is just a convenience method, as you can call
|
13
|
+
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
|
14
|
+
*
|
15
|
+
* For convenience, you can also pass an action creator as the first argument,
|
16
|
+
* and get a dispatch wrapped function in return.
|
17
|
+
*
|
18
|
+
* @param {Function|Object} actionCreators An object whose values are action
|
19
|
+
* creator functions. One handy way to obtain it is to use ES6 `import * as`
|
20
|
+
* syntax. You may also pass a single function.
|
21
|
+
*
|
22
|
+
* @param {Function} dispatch The `dispatch` function available on your Redux
|
23
|
+
* store.
|
24
|
+
*
|
25
|
+
* @returns {Function|Object} The object mimicking the original object, but with
|
26
|
+
* every action creator wrapped into the `dispatch` call. If you passed a
|
27
|
+
* function as `actionCreators`, the return value will also be a single
|
28
|
+
* function.
|
29
|
+
*/
|
30
|
+
export default function bindActionCreators(actionCreators, dispatch) {
|
31
|
+
if (typeof actionCreators === 'function') {
|
32
|
+
return bindActionCreator(actionCreators, dispatch)
|
33
|
+
}
|
34
|
+
|
35
|
+
if (typeof actionCreators !== 'object' || actionCreators === null) {
|
36
|
+
throw new Error(
|
37
|
+
`bindActionCreators expected an object or a function, but instead received: '${kindOf(
|
38
|
+
actionCreators
|
39
|
+
)}'. ` +
|
40
|
+
`Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?`
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
const boundActionCreators = {}
|
45
|
+
for (const key in actionCreators) {
|
46
|
+
const actionCreator = actionCreators[key]
|
47
|
+
if (typeof actionCreator === 'function') {
|
48
|
+
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch)
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return boundActionCreators
|
52
|
+
}
|
@@ -0,0 +1,175 @@
|
|
1
|
+
import ActionTypes from './utils/actionTypes'
|
2
|
+
import warning from './utils/warning'
|
3
|
+
import isPlainObject from './utils/isPlainObject'
|
4
|
+
import { kindOf } from './utils/kindOf'
|
5
|
+
|
6
|
+
function getUnexpectedStateShapeWarningMessage(
|
7
|
+
inputState,
|
8
|
+
reducers,
|
9
|
+
action,
|
10
|
+
unexpectedKeyCache
|
11
|
+
) {
|
12
|
+
const reducerKeys = Object.keys(reducers)
|
13
|
+
const argumentName =
|
14
|
+
action && action.type === ActionTypes.INIT
|
15
|
+
? 'preloadedState argument passed to createStore'
|
16
|
+
: 'previous state received by the reducer'
|
17
|
+
|
18
|
+
if (reducerKeys.length === 0) {
|
19
|
+
return (
|
20
|
+
'Store does not have a valid reducer. Make sure the argument passed ' +
|
21
|
+
'to combineReducers is an object whose values are reducers.'
|
22
|
+
)
|
23
|
+
}
|
24
|
+
|
25
|
+
if (!isPlainObject(inputState)) {
|
26
|
+
return (
|
27
|
+
`The ${argumentName} has unexpected type of "${kindOf(
|
28
|
+
inputState
|
29
|
+
)}". Expected argument to be an object with the following ` +
|
30
|
+
`keys: "${reducerKeys.join('", "')}"`
|
31
|
+
)
|
32
|
+
}
|
33
|
+
|
34
|
+
const unexpectedKeys = Object.keys(inputState).filter(
|
35
|
+
(key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]
|
36
|
+
)
|
37
|
+
|
38
|
+
unexpectedKeys.forEach((key) => {
|
39
|
+
unexpectedKeyCache[key] = true
|
40
|
+
})
|
41
|
+
|
42
|
+
if (action && action.type === ActionTypes.REPLACE) return
|
43
|
+
|
44
|
+
if (unexpectedKeys.length > 0) {
|
45
|
+
return (
|
46
|
+
`Unexpected ${unexpectedKeys.length > 1 ? 'keys' : 'key'} ` +
|
47
|
+
`"${unexpectedKeys.join('", "')}" found in ${argumentName}. ` +
|
48
|
+
`Expected to find one of the known reducer keys instead: ` +
|
49
|
+
`"${reducerKeys.join('", "')}". Unexpected keys will be ignored.`
|
50
|
+
)
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
function assertReducerShape(reducers) {
|
55
|
+
Object.keys(reducers).forEach((key) => {
|
56
|
+
const reducer = reducers[key]
|
57
|
+
const initialState = reducer(undefined, { type: ActionTypes.INIT })
|
58
|
+
|
59
|
+
if (typeof initialState === 'undefined') {
|
60
|
+
throw new Error(
|
61
|
+
`The slice reducer for key "${key}" returned undefined during initialization. ` +
|
62
|
+
`If the state passed to the reducer is undefined, you must ` +
|
63
|
+
`explicitly return the initial state. The initial state may ` +
|
64
|
+
`not be undefined. If you don't want to set a value for this reducer, ` +
|
65
|
+
`you can use null instead of undefined.`
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
69
|
+
if (
|
70
|
+
typeof reducer(undefined, {
|
71
|
+
type: ActionTypes.PROBE_UNKNOWN_ACTION(),
|
72
|
+
}) === 'undefined'
|
73
|
+
) {
|
74
|
+
throw new Error(
|
75
|
+
`The slice reducer for key "${key}" returned undefined when probed with a random type. ` +
|
76
|
+
`Don't try to handle '${ActionTypes.INIT}' or other actions in "redux/*" ` +
|
77
|
+
`namespace. They are considered private. Instead, you must return the ` +
|
78
|
+
`current state for any unknown actions, unless it is undefined, ` +
|
79
|
+
`in which case you must return the initial state, regardless of the ` +
|
80
|
+
`action type. The initial state may not be undefined, but can be null.`
|
81
|
+
)
|
82
|
+
}
|
83
|
+
})
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Turns an object whose values are different reducer functions, into a single
|
88
|
+
* reducer function. It will call every child reducer, and gather their results
|
89
|
+
* into a single state object, whose keys correspond to the keys of the passed
|
90
|
+
* reducer functions.
|
91
|
+
*
|
92
|
+
* @param {Object} reducers An object whose values correspond to different
|
93
|
+
* reducer functions that need to be combined into one. One handy way to obtain
|
94
|
+
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
95
|
+
* undefined for any action. Instead, they should return their initial state
|
96
|
+
* if the state passed to them was undefined, and the current state for any
|
97
|
+
* unrecognized action.
|
98
|
+
*
|
99
|
+
* @returns {Function} A reducer function that invokes every reducer inside the
|
100
|
+
* passed object, and builds a state object with the same shape.
|
101
|
+
*/
|
102
|
+
export default function combineReducers(reducers) {
|
103
|
+
const reducerKeys = Object.keys(reducers)
|
104
|
+
const finalReducers = {}
|
105
|
+
for (let i = 0; i < reducerKeys.length; i++) {
|
106
|
+
const key = reducerKeys[i]
|
107
|
+
|
108
|
+
if (process.env.NODE_ENV !== 'production') {
|
109
|
+
if (typeof reducers[key] === 'undefined') {
|
110
|
+
warning(`No reducer provided for key "${key}"`)
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
if (typeof reducers[key] === 'function') {
|
115
|
+
finalReducers[key] = reducers[key]
|
116
|
+
}
|
117
|
+
}
|
118
|
+
const finalReducerKeys = Object.keys(finalReducers)
|
119
|
+
|
120
|
+
// This is used to make sure we don't warn about the same
|
121
|
+
// keys multiple times.
|
122
|
+
let unexpectedKeyCache
|
123
|
+
if (process.env.NODE_ENV !== 'production') {
|
124
|
+
unexpectedKeyCache = {}
|
125
|
+
}
|
126
|
+
|
127
|
+
let shapeAssertionError
|
128
|
+
try {
|
129
|
+
assertReducerShape(finalReducers)
|
130
|
+
} catch (e) {
|
131
|
+
shapeAssertionError = e
|
132
|
+
}
|
133
|
+
|
134
|
+
return function combination(state = {}, action) {
|
135
|
+
if (shapeAssertionError) {
|
136
|
+
throw shapeAssertionError
|
137
|
+
}
|
138
|
+
|
139
|
+
if (process.env.NODE_ENV !== 'production') {
|
140
|
+
const warningMessage = getUnexpectedStateShapeWarningMessage(
|
141
|
+
state,
|
142
|
+
finalReducers,
|
143
|
+
action,
|
144
|
+
unexpectedKeyCache
|
145
|
+
)
|
146
|
+
if (warningMessage) {
|
147
|
+
warning(warningMessage)
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
let hasChanged = false
|
152
|
+
const nextState = {}
|
153
|
+
for (let i = 0; i < finalReducerKeys.length; i++) {
|
154
|
+
const key = finalReducerKeys[i]
|
155
|
+
const reducer = finalReducers[key]
|
156
|
+
const previousStateForKey = state[key]
|
157
|
+
const nextStateForKey = reducer(previousStateForKey, action)
|
158
|
+
if (typeof nextStateForKey === 'undefined') {
|
159
|
+
const actionType = action && action.type
|
160
|
+
throw new Error(
|
161
|
+
`When called with an action of type ${
|
162
|
+
actionType ? `"${String(actionType)}"` : '(unknown type)'
|
163
|
+
}, the slice reducer for key "${key}" returned undefined. ` +
|
164
|
+
`To ignore an action, you must explicitly return the previous state. ` +
|
165
|
+
`If you want this reducer to hold no value, you can return null instead of undefined.`
|
166
|
+
)
|
167
|
+
}
|
168
|
+
nextState[key] = nextStateForKey
|
169
|
+
hasChanged = hasChanged || nextStateForKey !== previousStateForKey
|
170
|
+
}
|
171
|
+
hasChanged =
|
172
|
+
hasChanged || finalReducerKeys.length !== Object.keys(state).length
|
173
|
+
return hasChanged ? nextState : state
|
174
|
+
}
|
175
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Composes single-argument functions from right to left. The rightmost
|
3
|
+
* function can take multiple arguments as it provides the signature for
|
4
|
+
* the resulting composite function.
|
5
|
+
*
|
6
|
+
* @param {...Function} funcs The functions to compose.
|
7
|
+
* @returns {Function} A function obtained by composing the argument functions
|
8
|
+
* from right to left. For example, compose(f, g, h) is identical to doing
|
9
|
+
* (...args) => f(g(h(...args))).
|
10
|
+
*/
|
11
|
+
|
12
|
+
export default function compose(...funcs) {
|
13
|
+
if (funcs.length === 0) {
|
14
|
+
return (arg) => arg
|
15
|
+
}
|
16
|
+
|
17
|
+
if (funcs.length === 1) {
|
18
|
+
return funcs[0]
|
19
|
+
}
|
20
|
+
|
21
|
+
return funcs.reduce((a, b) => (...args) => a(b(...args)))
|
22
|
+
}
|
@@ -0,0 +1,315 @@
|
|
1
|
+
import $$observable from './utils/symbol-observable'
|
2
|
+
|
3
|
+
import ActionTypes from './utils/actionTypes'
|
4
|
+
import isPlainObject from './utils/isPlainObject'
|
5
|
+
import { kindOf } from './utils/kindOf'
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Creates a Redux store that holds the state tree.
|
9
|
+
* The only way to change the data in the store is to call `dispatch()` on it.
|
10
|
+
*
|
11
|
+
* There should only be a single store in your app. To specify how different
|
12
|
+
* parts of the state tree respond to actions, you may combine several reducers
|
13
|
+
* into a single reducer function by using `combineReducers`.
|
14
|
+
*
|
15
|
+
* @param {Function} reducer A function that returns the next state tree, given
|
16
|
+
* the current state tree and the action to handle.
|
17
|
+
*
|
18
|
+
* @param {any} [preloadedState] The initial state. You may optionally specify it
|
19
|
+
* to hydrate the state from the server in universal apps, or to restore a
|
20
|
+
* previously serialized user session.
|
21
|
+
* If you use `combineReducers` to produce the root reducer function, this must be
|
22
|
+
* an object with the same shape as `combineReducers` keys.
|
23
|
+
*
|
24
|
+
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
|
25
|
+
* to enhance the store with third-party capabilities such as middleware,
|
26
|
+
* time travel, persistence, etc. The only store enhancer that ships with Redux
|
27
|
+
* is `applyMiddleware()`.
|
28
|
+
*
|
29
|
+
* @returns {Store} A Redux store that lets you read the state, dispatch actions
|
30
|
+
* and subscribe to changes.
|
31
|
+
*/
|
32
|
+
export default function createStore(reducer, preloadedState, enhancer) {
|
33
|
+
if (
|
34
|
+
(typeof preloadedState === 'function' && typeof enhancer === 'function') ||
|
35
|
+
(typeof enhancer === 'function' && typeof arguments[3] === 'function')
|
36
|
+
) {
|
37
|
+
throw new Error(
|
38
|
+
'It looks like you are passing several store enhancers to ' +
|
39
|
+
'createStore(). This is not supported. Instead, compose them ' +
|
40
|
+
'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.'
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
45
|
+
enhancer = preloadedState
|
46
|
+
preloadedState = undefined
|
47
|
+
}
|
48
|
+
|
49
|
+
if (typeof enhancer !== 'undefined') {
|
50
|
+
if (typeof enhancer !== 'function') {
|
51
|
+
throw new Error(
|
52
|
+
`Expected the enhancer to be a function. Instead, received: '${kindOf(
|
53
|
+
enhancer
|
54
|
+
)}'`
|
55
|
+
)
|
56
|
+
}
|
57
|
+
|
58
|
+
return enhancer(createStore)(reducer, preloadedState)
|
59
|
+
}
|
60
|
+
|
61
|
+
if (typeof reducer !== 'function') {
|
62
|
+
throw new Error(
|
63
|
+
`Expected the root reducer to be a function. Instead, received: '${kindOf(
|
64
|
+
reducer
|
65
|
+
)}'`
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
69
|
+
let currentReducer = reducer
|
70
|
+
let currentState = preloadedState
|
71
|
+
let currentListeners = []
|
72
|
+
let nextListeners = currentListeners
|
73
|
+
let isDispatching = false
|
74
|
+
|
75
|
+
/**
|
76
|
+
* This makes a shallow copy of currentListeners so we can use
|
77
|
+
* nextListeners as a temporary list while dispatching.
|
78
|
+
*
|
79
|
+
* This prevents any bugs around consumers calling
|
80
|
+
* subscribe/unsubscribe in the middle of a dispatch.
|
81
|
+
*/
|
82
|
+
function ensureCanMutateNextListeners() {
|
83
|
+
if (nextListeners === currentListeners) {
|
84
|
+
nextListeners = currentListeners.slice()
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Reads the state tree managed by the store.
|
90
|
+
*
|
91
|
+
* @returns {any} The current state tree of your application.
|
92
|
+
*/
|
93
|
+
function getState() {
|
94
|
+
if (isDispatching) {
|
95
|
+
throw new Error(
|
96
|
+
'You may not call store.getState() while the reducer is executing. ' +
|
97
|
+
'The reducer has already received the state as an argument. ' +
|
98
|
+
'Pass it down from the top reducer instead of reading it from the store.'
|
99
|
+
)
|
100
|
+
}
|
101
|
+
|
102
|
+
return currentState
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Adds a change listener. It will be called any time an action is dispatched,
|
107
|
+
* and some part of the state tree may potentially have changed. You may then
|
108
|
+
* call `getState()` to read the current state tree inside the callback.
|
109
|
+
*
|
110
|
+
* You may call `dispatch()` from a change listener, with the following
|
111
|
+
* caveats:
|
112
|
+
*
|
113
|
+
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
114
|
+
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
115
|
+
* will not have any effect on the `dispatch()` that is currently in progress.
|
116
|
+
* However, the next `dispatch()` call, whether nested or not, will use a more
|
117
|
+
* recent snapshot of the subscription list.
|
118
|
+
*
|
119
|
+
* 2. The listener should not expect to see all state changes, as the state
|
120
|
+
* might have been updated multiple times during a nested `dispatch()` before
|
121
|
+
* the listener is called. It is, however, guaranteed that all subscribers
|
122
|
+
* registered before the `dispatch()` started will be called with the latest
|
123
|
+
* state by the time it exits.
|
124
|
+
*
|
125
|
+
* @param {Function} listener A callback to be invoked on every dispatch.
|
126
|
+
* @returns {Function} A function to remove this change listener.
|
127
|
+
*/
|
128
|
+
function subscribe(listener) {
|
129
|
+
if (typeof listener !== 'function') {
|
130
|
+
throw new Error(
|
131
|
+
`Expected the listener to be a function. Instead, received: '${kindOf(
|
132
|
+
listener
|
133
|
+
)}'`
|
134
|
+
)
|
135
|
+
}
|
136
|
+
|
137
|
+
if (isDispatching) {
|
138
|
+
throw new Error(
|
139
|
+
'You may not call store.subscribe() while the reducer is executing. ' +
|
140
|
+
'If you would like to be notified after the store has been updated, subscribe from a ' +
|
141
|
+
'component and invoke store.getState() in the callback to access the latest state. ' +
|
142
|
+
'See https://redux.js.org/api/store#subscribelistener for more details.'
|
143
|
+
)
|
144
|
+
}
|
145
|
+
|
146
|
+
let isSubscribed = true
|
147
|
+
|
148
|
+
ensureCanMutateNextListeners()
|
149
|
+
nextListeners.push(listener)
|
150
|
+
|
151
|
+
return function unsubscribe() {
|
152
|
+
if (!isSubscribed) {
|
153
|
+
return
|
154
|
+
}
|
155
|
+
|
156
|
+
if (isDispatching) {
|
157
|
+
throw new Error(
|
158
|
+
'You may not unsubscribe from a store listener while the reducer is executing. ' +
|
159
|
+
'See https://redux.js.org/api/store#subscribelistener for more details.'
|
160
|
+
)
|
161
|
+
}
|
162
|
+
|
163
|
+
isSubscribed = false
|
164
|
+
|
165
|
+
ensureCanMutateNextListeners()
|
166
|
+
const index = nextListeners.indexOf(listener)
|
167
|
+
nextListeners.splice(index, 1)
|
168
|
+
currentListeners = null
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Dispatches an action. It is the only way to trigger a state change.
|
174
|
+
*
|
175
|
+
* The `reducer` function, used to create the store, will be called with the
|
176
|
+
* current state tree and the given `action`. Its return value will
|
177
|
+
* be considered the **next** state of the tree, and the change listeners
|
178
|
+
* will be notified.
|
179
|
+
*
|
180
|
+
* The base implementation only supports plain object actions. If you want to
|
181
|
+
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
182
|
+
* wrap your store creating function into the corresponding middleware. For
|
183
|
+
* example, see the documentation for the `redux-thunk` package. Even the
|
184
|
+
* middleware will eventually dispatch plain object actions using this method.
|
185
|
+
*
|
186
|
+
* @param {Object} action A plain object representing “what changed”. It is
|
187
|
+
* a good idea to keep actions serializable so you can record and replay user
|
188
|
+
* sessions, or use the time travelling `redux-devtools`. An action must have
|
189
|
+
* a `type` property which may not be `undefined`. It is a good idea to use
|
190
|
+
* string constants for action types.
|
191
|
+
*
|
192
|
+
* @returns {Object} For convenience, the same action object you dispatched.
|
193
|
+
*
|
194
|
+
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
195
|
+
* return something else (for example, a Promise you can await).
|
196
|
+
*/
|
197
|
+
function dispatch(action) {
|
198
|
+
if (!isPlainObject(action)) {
|
199
|
+
throw new Error(
|
200
|
+
`Actions must be plain objects. Instead, the actual type was: '${kindOf(
|
201
|
+
action
|
202
|
+
)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`
|
203
|
+
)
|
204
|
+
}
|
205
|
+
|
206
|
+
if (typeof action.type === 'undefined') {
|
207
|
+
throw new Error(
|
208
|
+
'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.'
|
209
|
+
)
|
210
|
+
}
|
211
|
+
|
212
|
+
if (isDispatching) {
|
213
|
+
throw new Error('Reducers may not dispatch actions.')
|
214
|
+
}
|
215
|
+
|
216
|
+
try {
|
217
|
+
isDispatching = true
|
218
|
+
currentState = currentReducer(currentState, action)
|
219
|
+
} finally {
|
220
|
+
isDispatching = false
|
221
|
+
}
|
222
|
+
|
223
|
+
const listeners = (currentListeners = nextListeners)
|
224
|
+
for (let i = 0; i < listeners.length; i++) {
|
225
|
+
const listener = listeners[i]
|
226
|
+
listener()
|
227
|
+
}
|
228
|
+
|
229
|
+
return action
|
230
|
+
}
|
231
|
+
|
232
|
+
/**
|
233
|
+
* Replaces the reducer currently used by the store to calculate the state.
|
234
|
+
*
|
235
|
+
* You might need this if your app implements code splitting and you want to
|
236
|
+
* load some of the reducers dynamically. You might also need this if you
|
237
|
+
* implement a hot reloading mechanism for Redux.
|
238
|
+
*
|
239
|
+
* @param {Function} nextReducer The reducer for the store to use instead.
|
240
|
+
* @returns {void}
|
241
|
+
*/
|
242
|
+
function replaceReducer(nextReducer) {
|
243
|
+
if (typeof nextReducer !== 'function') {
|
244
|
+
throw new Error(
|
245
|
+
`Expected the nextReducer to be a function. Instead, received: '${kindOf(
|
246
|
+
nextReducer
|
247
|
+
)}`
|
248
|
+
)
|
249
|
+
}
|
250
|
+
|
251
|
+
currentReducer = nextReducer
|
252
|
+
|
253
|
+
// This action has a similiar effect to ActionTypes.INIT.
|
254
|
+
// Any reducers that existed in both the new and old rootReducer
|
255
|
+
// will receive the previous state. This effectively populates
|
256
|
+
// the new state tree with any relevant data from the old one.
|
257
|
+
dispatch({ type: ActionTypes.REPLACE })
|
258
|
+
}
|
259
|
+
|
260
|
+
/**
|
261
|
+
* Interoperability point for observable/reactive libraries.
|
262
|
+
* @returns {observable} A minimal observable of state changes.
|
263
|
+
* For more information, see the observable proposal:
|
264
|
+
* https://github.com/tc39/proposal-observable
|
265
|
+
*/
|
266
|
+
function observable() {
|
267
|
+
const outerSubscribe = subscribe
|
268
|
+
return {
|
269
|
+
/**
|
270
|
+
* The minimal observable subscription method.
|
271
|
+
* @param {Object} observer Any object that can be used as an observer.
|
272
|
+
* The observer object should have a `next` method.
|
273
|
+
* @returns {subscription} An object with an `unsubscribe` method that can
|
274
|
+
* be used to unsubscribe the observable from the store, and prevent further
|
275
|
+
* emission of values from the observable.
|
276
|
+
*/
|
277
|
+
subscribe(observer) {
|
278
|
+
if (typeof observer !== 'object' || observer === null) {
|
279
|
+
throw new TypeError(
|
280
|
+
`Expected the observer to be an object. Instead, received: '${kindOf(
|
281
|
+
observer
|
282
|
+
)}'`
|
283
|
+
)
|
284
|
+
}
|
285
|
+
|
286
|
+
function observeState() {
|
287
|
+
if (observer.next) {
|
288
|
+
observer.next(getState())
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
observeState()
|
293
|
+
const unsubscribe = outerSubscribe(observeState)
|
294
|
+
return { unsubscribe }
|
295
|
+
},
|
296
|
+
|
297
|
+
[$$observable]() {
|
298
|
+
return this
|
299
|
+
},
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
// When a store is created, an "INIT" action is dispatched so that every
|
304
|
+
// reducer returns their initial state. This effectively populates
|
305
|
+
// the initial state tree.
|
306
|
+
dispatch({ type: ActionTypes.INIT })
|
307
|
+
|
308
|
+
return {
|
309
|
+
dispatch,
|
310
|
+
subscribe,
|
311
|
+
getState,
|
312
|
+
replaceReducer,
|
313
|
+
[$$observable]: observable,
|
314
|
+
}
|
315
|
+
}
|