@inglorious/store 12.6.2 → 12.8.0
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/README.md +30 -1856
- package/package.json +2 -2
- package/src/behaviors/optimistic.js +1 -1
- package/src/behaviors/state-machine/fsm.js +4 -8
- package/src/behaviors/state-machine/scenes.js +8 -28
- package/src/client/devtools.js +33 -54
- package/src/client/event-filter.js +20 -0
- package/src/client/multiplayer-middleware.js +4 -8
- package/src/migration/rtk.js +1 -1
- package/src/store.js +432 -230
- package/types/store.d.ts +9 -9
package/types/store.d.ts
CHANGED
|
@@ -213,20 +213,18 @@ export type TypesConfig<
|
|
|
213
213
|
export type UpdateMode = "auto" | "manual"
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
|
-
* How
|
|
216
|
+
* How an event's changes are copied.
|
|
217
217
|
*
|
|
218
|
-
* - `"structural-sharing"` (default) applies
|
|
219
|
-
* actually changed are copied. Unchanged entities keep their previous reference, which keeps
|
|
218
|
+
* - `"structural-sharing"` (default) applies each event to a draft proxy, so only the entities
|
|
219
|
+
* that actually changed are copied. Unchanged entities keep their previous reference, which keeps
|
|
220
220
|
* reference-equality change detection cheap. Best for UI stores.
|
|
221
|
-
* - `"copy-on-dispatch"` deep-copies each entity the first time
|
|
222
|
-
* system, and applies
|
|
221
|
+
* - `"copy-on-dispatch"` deep-copies each entity the first time an event hands it to a handler or a
|
|
222
|
+
* system, and applies the event to the copy without a proxy. Entities nothing touches are not
|
|
223
223
|
* copied, and there is no per-entity proxy overhead, so it scales better when thousands of
|
|
224
224
|
* entities change every frame, as in a game simulation.
|
|
225
225
|
*
|
|
226
|
-
* Under both strategies
|
|
227
|
-
*
|
|
228
|
-
* that during an update `api.getEntity()` and `api.getEntities()` read the previous state rather
|
|
229
|
-
* than the in-flight changes.
|
|
226
|
+
* Under both strategies each event is a transaction: its handlers read, through the api, the state
|
|
227
|
+
* as the previous event left it, and the next event reads what they changed.
|
|
230
228
|
*/
|
|
231
229
|
export type UpdateStrategy = "structural-sharing" | "copy-on-dispatch"
|
|
232
230
|
|
|
@@ -248,6 +246,8 @@ export interface StoreConfig<
|
|
|
248
246
|
autoCreateEntities?: boolean
|
|
249
247
|
updateMode?: UpdateMode
|
|
250
248
|
updateStrategy?: UpdateStrategy
|
|
249
|
+
/** Freezes the state after each event under structural sharing, so a write outside a handler throws. */
|
|
250
|
+
devMode?: boolean
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
/**
|