As a developer building a performance-critical application with FluentState, I want to optimize how state updates are processed and monitored, so that I can minimize performance bottlenecks, reduce unnecessary re-renders, and gain insights into my application's state management behavior.
Acceptance Criteria:
-
Batched Updates
- Multiple state updates occurring within the configured time window are batched into a single update
- The batchTimeWindow parameter controls how long to wait before processing batched updates
- Batching can be enabled/disabled globally via the batchUpdates configuration option
- Batched updates maintain the same final state as if updates were processed individually
-
Memoization Support
- When enableMemoization is true, derived values from state are cached and only recalculated when dependencies change
- Memoization works with both simple and complex state structures
- Memoized values are properly invalidated when their dependencies change
- Memory usage is optimized by clearing unused memoized values
-
Custom Equality Checking
- Developers can provide a custom areEqual function to determine if state has actually changed
- The custom equality function is used to prevent unnecessary updates when state is structurally equivalent
- Default equality checking uses a shallow comparison for objects and arrays
- Custom equality checking works with all state update methods
-
Performance Metrics
- When metrics.enabled is true, the state manager collects performance data
- Update frequency, duration, and count are tracked when measureUpdates is true
- Memory usage statistics are collected when measureMemory is true
- Computation timing for equality checks, memoization, and derivations is measured when measureComputations is true
- Metrics are provided to the onMetrics callback for custom reporting or visualization
- Metrics collection has minimal impact on overall performance
As a developer building a performance-critical application with FluentState, I want to optimize how state updates are processed and monitored, so that I can minimize performance bottlenecks, reduce unnecessary re-renders, and gain insights into my application's state management behavior.
Acceptance Criteria:
Batched Updates
Memoization Support
Custom Equality Checking
Performance Metrics