fix(core): serialize state mutations, fix batch flushing/reentrancy, handle falsy initial values, dispose old StatePart on force, and improve notification/error handling

This commit is contained in:
2026-02-28 08:52:41 +00:00
parent 2f0b39ae41
commit 9312b8908c
8 changed files with 383 additions and 120 deletions

View File

@@ -1,5 +1,17 @@
# Changelog
## 2026-02-28 - 2.1.1 - fix(core)
serialize state mutations, fix batch flushing/reentrancy, handle falsy initial values, dispose old StatePart on force, and improve notification/error handling
- Serialize setState() and dispatchAction() using an internal mutation queue to prevent lost updates and race conditions.
- Prevent batch flush deadlocks by introducing isFlushing and draining pending notifications iteratively.
- Force initMode now disposes the previous StatePart so the Subject completes and resources are cleaned up.
- Treat falsy but non-null values (0, false) as present: getStatePart accepts 0 as initial value and waitUntilPresent resolves for false/0.
- Improve notifyChange: use a stable snapshot, catch and log hash computation errors, and avoid duplicate notifications; notifyChangeCumulative now safely catches async errors.
- Add StatePart.dispose() to complete the Subject and clear pending timers/middlewares.
- Add/adjust tests for concurrent dispatches, concurrent setState, disposal behavior, falsy state handling, batch re-entrancy, force-mode disposal, and zero initialization.
- Documentation and README improvements (examples, clearer descriptions, persistence notes) and minor code cleanup (remove unused import).
## 2026-02-27 - 2.1.0 - feat(smartstate)
Add middleware, computed, batching, selector memoization, AbortSignal support, and Web Component Context Protocol provider