张延森 4 years ago
parent
commit
169ca63102
1 changed files with 11 additions and 1 deletions
  1. 11
    1
      src/utils/store/executor.js

+ 11
- 1
src/utils/store/executor.js View File

@@ -19,6 +19,16 @@ import useUpdate from './utils/useUpdate'
19 19
 
20 20
 const noop = () => undefined
21 21
 
22
+const entries = obj => {
23
+  const ownProps = Object.keys( obj )
24
+  let i = ownProps.length
25
+  const resArray = new Array(i)
26
+  while (i--)
27
+    resArray[i] = [ownProps[i], obj[ownProps[i]]]
28
+
29
+  return resArray
30
+}
31
+
22 32
 // 所有的 Model 会分别被绑定到各自 Executor 上
23 33
 // 借用 Executor onUpdate 把 Model 的变化传递到各订阅的组件上
24 34
 export function Executor(props) {
@@ -53,7 +63,7 @@ export function createExecutors(store, models) {
53 63
     return (
54 64
       <>
55 65
       {
56
-        Object.entries(models).map(pair => {
66
+        entries(models).map(pair => {
57 67
           const [namespace, hook] = pair
58 68
           return <Executor key={namespace} namespace={namespace} model={hook} store={store} />
59 69
         })