-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem Statement
Complex applications need efficient ways to derive and memoize data from multiple signals without unnecessary recalculations. Current Computed is limited to simple scenarios.
Proposed Solution
Create an advanced selector system inspired by Redux selectors with automatic memoization, multi-signal dependencies, and performance optimizations.
Technical Specification
\\csharp
namespace BlazorSignalStore.Selectors
{
public class Selector : Signal
{
public static Selector Create(Signal signal1, Func<T1, T> selector);
public static Selector Create<T1, T2>(Signal signal1, Signal signal2, Func<T1, T2, T> selector);
public static Selector Create<T1, T2, T3>(Signal signal1, Signal signal2, Signal signal3, Func<T1, T2, T3, T> selector);
public bool IsStale { get; }
public DateTime LastCalculated { get; }
public void InvalidateCache();
}
public static class SelectorExtensions
{
public static Selector<TResult> Select<T, TResult>(this Signal<T> signal, Func<T, TResult> selector);
public static Selector<TResult> CombineLatest<T1, T2, TResult>(Signal<T1> signal1, Signal<T2> signal2, Func<T1, T2, TResult> combiner);
}
}
\\
Acceptance Criteria
- Create Selector class with automatic memoization
- Support selectors with 1-5 signal dependencies
- Implement efficient change detection and caching
- Add support for custom equality comparers
- Create fluent API with extension methods
- Support selector composition and chaining
- Add cache invalidation and staleness tracking
- Optimize performance for complex selector trees
- Add comprehensive unit tests (minimum 20 new tests)
- Create performance benchmarks comparing to Computed
- Update documentation with selector patterns
Implementation Notes
- Use WeakReference for memory-efficient caching
- Implement LRU cache for selector results
- Consider using expression trees for performance
- Add selector dependency visualization for DevTools
- Support async selectors for future async operations
Estimated Effort
10-12 hours
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request