cx 26.7.2 → 26.7.3

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.
package/dist/ui.js CHANGED
@@ -2129,10 +2129,10 @@ class Cx extends VDOM.Component {
2129
2129
  }
2130
2130
  this.state = {
2131
2131
  deferToken: 0,
2132
+ data: props.subscribe ? this.store.getData() : null,
2132
2133
  };
2133
2134
  if (props.subscribe) {
2134
2135
  this.unsubscribe = this.store.subscribe(this.update.bind(this));
2135
- this.state.data = this.store.getData();
2136
2136
  }
2137
2137
  this.onStateUpdateCompleted = this.onStateUpdateCompleted.bind(this);
2138
2138
  this.flags = {};
@@ -2214,19 +2214,22 @@ class Cx extends VDOM.Component {
2214
2214
  }
2215
2215
  } else {
2216
2216
  // standard mode: coalesce sequential store commands into a single deferred update
2217
- if (!this.pendingUpdateTimer) {
2218
- notifyBatchedUpdateStarting();
2219
- this.pendingUpdateTimer = setTimeout(() => {
2220
- delete this.pendingUpdateTimer;
2221
- // read fresh data at fire time so the coalesced update renders the latest store state
2222
- this.setState(
2223
- {
2224
- data: this.store.getData(),
2225
- },
2226
- notifyBatchedUpdateCompleted,
2227
- );
2228
- }, 0);
2229
- }
2217
+ this.scheduleStateUpdate();
2218
+ }
2219
+ }
2220
+ scheduleStateUpdate() {
2221
+ if (!this.pendingUpdateTimer) {
2222
+ notifyBatchedUpdateStarting();
2223
+ this.pendingUpdateTimer = setTimeout(() => {
2224
+ delete this.pendingUpdateTimer;
2225
+ // read fresh data at fire time so the coalesced update renders the latest store state
2226
+ this.setState(
2227
+ {
2228
+ data: this.store.getData(),
2229
+ },
2230
+ notifyBatchedUpdateCompleted,
2231
+ );
2232
+ }, 0);
2230
2233
  }
2231
2234
  }
2232
2235
  // Completion callback for the synchronous setState above. If the store changed while that update was
@@ -2236,17 +2239,19 @@ class Cx extends VDOM.Component {
2236
2239
  // a genuinely non-converging update loop is still caught by React's own max-update-depth guard.
2237
2240
  onStateUpdateCompleted() {
2238
2241
  let latestData = this.store.getData();
2242
+ notifyBatchedUpdateCompleted();
2239
2243
  if (this.state.data === latestData) {
2240
2244
  this.stateUpdateDepth = 0;
2241
- notifyBatchedUpdateCompleted();
2242
2245
  } else {
2243
2246
  this.stateUpdateDepth++;
2244
- this.setState(
2245
- {
2246
- data: latestData,
2247
- },
2248
- this.onStateUpdateCompleted,
2249
- );
2247
+ if (this.stateUpdateDepth < 20 && isBatchingUpdates())
2248
+ this.setState(
2249
+ {
2250
+ data: latestData,
2251
+ },
2252
+ this.onStateUpdateCompleted,
2253
+ );
2254
+ else this.scheduleStateUpdate();
2250
2255
  }
2251
2256
  }
2252
2257
  waitForIdle() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "26.7.2",
3
+ "version": "26.7.3",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "exports": {
6
6
  "./data": {
package/src/ui/Cx.tsx CHANGED
@@ -73,11 +73,11 @@ export class Cx extends VDOM.Component<CxProps, CxState> {
73
73
 
74
74
  this.state = {
75
75
  deferToken: 0,
76
+ data: props.subscribe ? this.store.getData() : null,
76
77
  };
77
78
 
78
79
  if (props.subscribe) {
79
80
  this.unsubscribe = this.store.subscribe(this.update.bind(this));
80
- (this.state as any).data = this.store.getData();
81
81
  }
82
82
 
83
83
  this.onStateUpdateCompleted = this.onStateUpdateCompleted.bind(this);
@@ -178,14 +178,18 @@ export class Cx extends VDOM.Component<CxProps, CxState> {
178
178
  }
179
179
  } else {
180
180
  // standard mode: coalesce sequential store commands into a single deferred update
181
- if (!this.pendingUpdateTimer) {
182
- notifyBatchedUpdateStarting();
183
- this.pendingUpdateTimer = setTimeout(() => {
184
- delete this.pendingUpdateTimer;
185
- // read fresh data at fire time so the coalesced update renders the latest store state
186
- this.setState({ data: this.store.getData() }, notifyBatchedUpdateCompleted);
187
- }, 0);
188
- }
181
+ this.scheduleStateUpdate();
182
+ }
183
+ }
184
+
185
+ scheduleStateUpdate() {
186
+ if (!this.pendingUpdateTimer) {
187
+ notifyBatchedUpdateStarting();
188
+ this.pendingUpdateTimer = setTimeout(() => {
189
+ delete this.pendingUpdateTimer;
190
+ // read fresh data at fire time so the coalesced update renders the latest store state
191
+ this.setState({ data: this.store.getData() }, notifyBatchedUpdateCompleted);
192
+ }, 0);
189
193
  }
190
194
  }
191
195
 
@@ -196,12 +200,14 @@ export class Cx extends VDOM.Component<CxProps, CxState> {
196
200
  // a genuinely non-converging update loop is still caught by React's own max-update-depth guard.
197
201
  onStateUpdateCompleted() {
198
202
  let latestData = this.store.getData();
203
+ notifyBatchedUpdateCompleted();
199
204
  if (this.state.data === latestData) {
200
205
  this.stateUpdateDepth = 0;
201
- notifyBatchedUpdateCompleted();
202
206
  } else {
203
207
  this.stateUpdateDepth++;
204
- this.setState({ data: latestData }, this.onStateUpdateCompleted);
208
+ if (this.stateUpdateDepth < 20 && isBatchingUpdates())
209
+ this.setState({ data: latestData }, this.onStateUpdateCompleted);
210
+ else this.scheduleStateUpdate();
205
211
  }
206
212
  }
207
213