plug-code 1.1.11 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/core/plcAPI.tsx +10 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plug-code",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "",
5
5
  "main": "src/plug-code.tsx",
6
6
  "types": "types/plug-code.d.ts",
@@ -70,35 +70,25 @@ export class PlcAPI<S extends ObjectType> {
70
70
  ) {
71
71
  let lastValue: any
72
72
 
73
- let isRunning = false
74
- let idleHandle: number | null = null
75
-
76
73
  const runUpdate = () => {
77
- if (isRunning) return
78
- if (idleHandle) cancelIdleCallback(idleHandle)
79
-
80
- idleHandle = requestIdleCallback(() => {
81
- isRunning = true
82
- try {
83
- const result = calculator()
84
- lastValue = result
85
- this.replace("root" as any, { [outputKey]: result })
86
- } finally {
87
- isRunning = false
88
- idleHandle = null
89
- }
90
- }, { timeout: 100 })
74
+ const result = calculator()
75
+ lastValue = result
76
+ this.replace("root" as any, { [outputKey]: result })
91
77
  }
92
78
 
79
+ // cálculo inicial inmediato
80
+ runUpdate()
81
+
82
+ // suscripción a dependencias
93
83
  dependencies.forEach(dep => {
94
- this.store.subscribe(dep as any, () => runUpdate())
84
+ this.store.subscribe(dep as any, runUpdate)
95
85
  })
96
86
 
97
- runUpdate()
98
-
99
87
  return () => lastValue
100
88
  }
101
89
 
90
+
91
+
102
92
  register(slot: SlotKey, node: () => React.ReactNode): void;
103
93
  register<K extends string>(slot: SlotKey, node: (data: any) => React.ReactNode, dependencyKey: K): void;
104
94
  register(slot: SlotKey, node: (data?: any) => React.ReactNode, dependencyKey?: string) {