|
6 | 6 | using EasyAppDev.Blazor.Store.Blazor; |
7 | 7 | using EasyAppDev.Blazor.Store.Persistence; |
8 | 8 | using Microsoft.JSInterop; |
| 9 | +#if DEBUG |
9 | 10 | using EasyAppDev.Blazor.Store.Diagnostics; |
| 11 | +#endif |
10 | 12 | using EasyAppDev.Blazor.Store.AsyncActions; |
11 | 13 | using EasyAppDev.Blazor.Store.Utilities; |
12 | 14 |
|
|
16 | 18 |
|
17 | 19 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
18 | 20 |
|
19 | | -// Register diagnostics service - only active in DEBUG builds |
| 21 | +// Register diagnostics service - only available in DEBUG builds |
| 22 | +#if DEBUG |
20 | 23 | builder.Services.AddStoreDiagnostics(); |
| 24 | +#endif |
21 | 25 |
|
22 | 26 | // Register utility services required by StoreComponent |
23 | 27 | // Note: AddStoreUtilities() registers IDebounceManager, IThrottleManager, and ILazyCache |
|
34 | 38 | // ============================================================================ |
35 | 39 | builder.Services.AddStore( |
36 | 40 | new CounterState(0), |
37 | | - (store, sp) => store.WithDefaults(sp, "Counter Store") |
38 | | - .WithDiagnosticsIfAvailable(sp)); |
| 41 | + (store, sp) => store.WithDefaults(sp, "Counter Store")); |
39 | 42 |
|
40 | 43 | // ============================================================================ |
41 | 44 | // Debounce Store - Demonstrates debounce and throttle functionality |
42 | 45 | // ============================================================================ |
43 | 46 | builder.Services.AddStore( |
44 | 47 | new DebounceState(), |
45 | | - (store, sp) => store.WithDefaults(sp, "Debounce Store") |
46 | | - .WithDiagnosticsIfAvailable(sp)); |
| 48 | + (store, sp) => store.WithDefaults(sp, "Debounce Store")); |
47 | 49 |
|
48 | 50 | // ============================================================================ |
49 | 51 | // Todo Store - Demonstrates immutable collections (ImmutableList) |
50 | 52 | // ============================================================================ |
51 | 53 | builder.Services.AddStore( |
52 | 54 | TodoState.Empty, |
53 | | - (store, sp) => store.WithDefaults(sp, "Todo Store") |
54 | | - .WithDiagnosticsIfAvailable(sp)); |
| 55 | + (store, sp) => store.WithDefaults(sp, "Todo Store")); |
55 | 56 |
|
56 | 57 | // ============================================================================ |
57 | 58 | // User Profile Store - Demonstrates async actions and loading states |
58 | 59 | // ============================================================================ |
59 | 60 | builder.Services.AddStore( |
60 | 61 | UserProfileState.Empty, |
61 | | - (store, sp) => store.WithDefaults(sp, "User Profile Store") |
62 | | - .WithDiagnosticsIfAvailable(sp)); |
| 62 | + (store, sp) => store.WithDefaults(sp, "User Profile Store")); |
63 | 63 |
|
64 | 64 | // ============================================================================ |
65 | 65 | // AsyncData Demo Store - Demonstrates AsyncData<T> wrapper pattern |
66 | 66 | // Simplifies async state from 20+ lines to 1 property! |
67 | 67 | // ============================================================================ |
68 | 68 | builder.Services.AddStore( |
69 | 69 | AsyncDataDemoState.Initial, |
70 | | - (store, sp) => store.WithDefaults(sp, "AsyncData Demo Store") |
71 | | - .WithDiagnosticsIfAvailable(sp)); |
| 70 | + (store, sp) => store.WithDefaults(sp, "AsyncData Demo Store")); |
72 | 71 |
|
73 | 72 | // ============================================================================ |
74 | 73 | // User Management Store - Demonstrates ExecuteAsync helper |
75 | 74 | // Automatic error handling - reduces try-catch from 12+ lines to 5 lines! |
76 | 75 | // ============================================================================ |
77 | 76 | builder.Services.AddStore( |
78 | 77 | UserManagementState.Initial, |
79 | | - (store, sp) => store.WithDefaults(sp, "User Management Store") |
80 | | - .WithDiagnosticsIfAvailable(sp)); |
| 78 | + (store, sp) => store.WithDefaults(sp, "User Management Store")); |
81 | 79 |
|
82 | 80 | // ============================================================================ |
83 | 81 | // Shopping Cart Store - Demonstrates persistence with LocalStorage |
|
87 | 85 | builder.Services.AddStore( |
88 | 86 | ShoppingCartState.Empty, |
89 | 87 | (store, sp) => store.WithDefaults(sp, "Shopping Cart Store") |
90 | | - .WithPersistence(sp, "shopping-cart-state") |
91 | | - .WithDiagnosticsIfAvailable(sp)); |
| 88 | + .WithPersistence(sp, "shopping-cart-state")); |
92 | 89 |
|
93 | 90 | // ============================================================================ |
94 | 91 | // Theme Store - Demonstrates selector optimization with SelectorStoreComponent |
|
98 | 95 | builder.Services.AddStore( |
99 | 96 | ThemeState.Default, |
100 | 97 | (store, sp) => store.WithDefaults(sp, "Theme Store") |
101 | | - .WithPersistence(sp, "theme-state") |
102 | | - .WithDiagnosticsIfAvailable(sp)); |
| 98 | + .WithPersistence(sp, "theme-state")); |
103 | 99 |
|
104 | 100 | // ============================================================================ |
105 | 101 | // Product Catalog Store - Demonstrates LazyLoad with caching |
106 | 102 | // Automatic caching with request deduplication - no manual cache management! |
107 | 103 | // ============================================================================ |
108 | 104 | builder.Services.AddStore( |
109 | 105 | new ProductCatalogState(), |
110 | | - (store, sp) => store.WithDefaults(sp, "Product Catalog Store") |
111 | | - .WithDiagnosticsIfAvailable(sp)); |
| 106 | + (store, sp) => store.WithDefaults(sp, "Product Catalog Store")); |
112 | 107 |
|
113 | 108 | // ============================================================================ |
114 | 109 | // Comprehensive Demo Store - Demonstrates ALL async helpers working together |
|
117 | 112 | // ============================================================================ |
118 | 113 | builder.Services.AddStore( |
119 | 114 | ComprehensiveDemoState.Initial, |
120 | | - (store, sp) => store.WithDefaults(sp, "Comprehensive Demo Store") |
121 | | - .WithDiagnosticsIfAvailable(sp)); |
| 115 | + (store, sp) => store.WithDefaults(sp, "Comprehensive Demo Store")); |
122 | 116 |
|
123 | 117 | // ============================================================================ |
124 | 118 | // Form Validation Store - Demonstrates form state management and validation |
|
127 | 121 | // ============================================================================ |
128 | 122 | builder.Services.AddStore( |
129 | 123 | new FormValidationState(), |
130 | | - (store, sp) => store.WithDefaults(sp, "Form Validation Store") |
131 | | - .WithDiagnosticsIfAvailable(sp)); |
| 124 | + (store, sp) => store.WithDefaults(sp, "Form Validation Store")); |
132 | 125 |
|
133 | 126 | // ============================================================================ |
134 | 127 | // Cross-Store Demo Stores - Demonstrates Phase 1 updates |
|
137 | 130 | // ============================================================================ |
138 | 131 | builder.Services.AddStore( |
139 | 132 | AuthDemoState.Initial, |
140 | | - (store, sp) => store.WithDefaults(sp, "Auth Demo Store") |
141 | | - .WithDiagnosticsIfAvailable(sp)); |
| 133 | + (store, sp) => store.WithDefaults(sp, "Auth Demo Store")); |
142 | 134 |
|
143 | 135 | builder.Services.AddStore( |
144 | 136 | CartDemoState.Empty, |
145 | | - (store, sp) => store.WithDefaults(sp, "Cart Demo Store") |
146 | | - .WithDiagnosticsIfAvailable(sp)); |
| 137 | + (store, sp) => store.WithDefaults(sp, "Cart Demo Store")); |
147 | 138 |
|
148 | 139 | await builder.Build().RunAsync(); |
0 commit comments