@@ -53,9 +53,6 @@ public static IServiceCollection AddStoreWithUtilities<TState>(
5353 {
5454 services . AddStoreUtilities ( ) ;
5555 services . AddStore ( initialState , configure ) ;
56-
57- // Register IStateWriter<TState> as an alias for IStore<TState> (required by AsyncActionExecutor)
58- services . AddSingleton < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
5956 services . AddAsyncActionExecutor < TState > ( ) ;
6057
6158 return services ;
@@ -77,9 +74,6 @@ public static IServiceCollection AddScopedStoreWithUtilities<TState>(
7774 {
7875 services . AddStoreUtilities ( ) ;
7976 services . AddScopedStore ( initialState , configure ) ;
80-
81- // Register IStateWriter<TState> as an alias for IStore<TState> (required by AsyncActionExecutor)
82- services . AddScoped < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
8377 services . AddAsyncActionExecutor < TState > ( ) ;
8478
8579 return services ;
@@ -101,16 +95,14 @@ public static IServiceCollection AddScopedStoreWithUtilities<TState>(
10195 {
10296 services . AddStoreUtilities ( ) ;
10397 services . AddScopedStore ( stateFactory , configure ) ;
104-
105- // Register IStateWriter<TState> as an alias for IStore<TState> (required by AsyncActionExecutor)
106- services . AddScoped < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
10798 services . AddAsyncActionExecutor < TState > ( ) ;
10899
109100 return services ;
110101 }
111102
112103 /// <summary>
113104 /// Adds a singleton store to the service collection.
105+ /// Also registers IStateReader, IStateWriter, and IStateObservable as aliases.
114106 /// </summary>
115107 /// <typeparam name="TState">The type of state.</typeparam>
116108 /// <param name="services">The service collection.</param>
@@ -131,11 +123,17 @@ public static IServiceCollection AddStore<TState>(
131123 return builder . Build ( ) ;
132124 } ) ;
133125
126+ // Register interface aliases (required by AsyncActionExecutor and for interface segregation)
127+ services . AddSingleton < IStateReader < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
128+ services . AddSingleton < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
129+ services . AddSingleton < IStateObservable < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
130+
134131 return services ;
135132 }
136133
137134 /// <summary>
138135 /// Adds a singleton store to the service collection using a factory.
136+ /// Also registers IStateReader, IStateWriter, and IStateObservable as aliases.
139137 /// </summary>
140138 /// <typeparam name="TState">The type of state.</typeparam>
141139 /// <param name="services">The service collection.</param>
@@ -156,11 +154,17 @@ public static IServiceCollection AddStore<TState>(
156154 return builder . Build ( ) ;
157155 } ) ;
158156
157+ // Register interface aliases (required by AsyncActionExecutor and for interface segregation)
158+ services . AddSingleton < IStateReader < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
159+ services . AddSingleton < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
160+ services . AddSingleton < IStateObservable < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
161+
159162 return services ;
160163 }
161164
162165 /// <summary>
163166 /// Adds a scoped store to the service collection.
167+ /// Also registers IStateReader, IStateWriter, and IStateObservable as aliases.
164168 /// </summary>
165169 /// <typeparam name="TState">The type of state.</typeparam>
166170 /// <param name="services">The service collection.</param>
@@ -181,11 +185,17 @@ public static IServiceCollection AddScopedStore<TState>(
181185 return builder . Build ( ) ;
182186 } ) ;
183187
188+ // Register interface aliases (required by AsyncActionExecutor and for interface segregation)
189+ services . AddScoped < IStateReader < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
190+ services . AddScoped < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
191+ services . AddScoped < IStateObservable < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
192+
184193 return services ;
185194 }
186195
187196 /// <summary>
188197 /// Adds a scoped store to the service collection (legacy overload for backward compatibility).
198+ /// Also registers IStateReader, IStateWriter, and IStateObservable as aliases.
189199 /// </summary>
190200 /// <typeparam name="TState">The type of state.</typeparam>
191201 /// <param name="services">The service collection.</param>
@@ -206,11 +216,17 @@ public static IServiceCollection AddScopedStore<TState>(
206216 return builder . Build ( ) ;
207217 } ) ;
208218
219+ // Register interface aliases (required by AsyncActionExecutor and for interface segregation)
220+ services . AddScoped < IStateReader < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
221+ services . AddScoped < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
222+ services . AddScoped < IStateObservable < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
223+
209224 return services ;
210225 }
211226
212227 /// <summary>
213228 /// Adds a scoped store to the service collection using a factory.
229+ /// Also registers IStateReader, IStateWriter, and IStateObservable as aliases.
214230 /// </summary>
215231 /// <typeparam name="TState">The type of state.</typeparam>
216232 /// <param name="services">The service collection.</param>
@@ -232,11 +248,17 @@ public static IServiceCollection AddScopedStore<TState>(
232248 return builder . Build ( ) ;
233249 } ) ;
234250
251+ // Register interface aliases (required by AsyncActionExecutor and for interface segregation)
252+ services . AddScoped < IStateReader < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
253+ services . AddScoped < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
254+ services . AddScoped < IStateObservable < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
255+
235256 return services ;
236257 }
237258
238259 /// <summary>
239260 /// Adds a scoped store to the service collection using a factory (legacy overload for backward compatibility).
261+ /// Also registers IStateReader, IStateWriter, and IStateObservable as aliases.
240262 /// </summary>
241263 /// <typeparam name="TState">The type of state.</typeparam>
242264 /// <param name="services">The service collection.</param>
@@ -258,12 +280,18 @@ public static IServiceCollection AddScopedStore<TState>(
258280 return builder . Build ( ) ;
259281 } ) ;
260282
283+ // Register interface aliases (required by AsyncActionExecutor and for interface segregation)
284+ services . AddScoped < IStateReader < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
285+ services . AddScoped < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
286+ services . AddScoped < IStateObservable < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
287+
261288 return services ;
262289 }
263290
264291 /// <summary>
265292 /// Adds a transient store to the service collection.
266293 /// Creates a new store instance each time it's requested.
294+ /// Also registers IStateReader, IStateWriter, and IStateObservable as aliases.
267295 /// </summary>
268296 /// <typeparam name="TState">The type of state.</typeparam>
269297 /// <param name="services">The service collection.</param>
@@ -284,6 +312,11 @@ public static IServiceCollection AddTransientStore<TState>(
284312 return builder . Build ( ) ;
285313 } ) ;
286314
315+ // Register interface aliases (required by AsyncActionExecutor and for interface segregation)
316+ services . AddTransient < IStateReader < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
317+ services . AddTransient < IStateWriter < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
318+ services . AddTransient < IStateObservable < TState > > ( sp => sp . GetRequiredService < IStore < TState > > ( ) ) ;
319+
287320 return services ;
288321 }
289322}
0 commit comments