-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expose public API for configuring DefaultExceptionHandler without builder #4302
Description
Context
Raised in #4296 by @ChaseFlorell. After upgrading, RxState.DefaultExceptionHandler only has a public getter — the InitializeExceptionHandler method is internal and only callable via ReactiveUIBuilder.WithExceptionHandler(). Users who have existing bootstrap pipelines (e.g., Blazor WASM, ASP.NET Core) and don't use RxAppBuilder have no way to set a custom exception handler.
Problem
// This used to work — now causes a compile error:
RxState.DefaultExceptionHandler = host.Services.GetService<IObserver<Exception>>();The only path today is:
RxAppBuilder.CreateReactiveUIBuilder()
.WithExceptionHandler(myHandler)
.BuildApp();For users with existing DI and bootstrap pipelines, this forces adoption of the full builder pattern just to set one global setting.
Proposed Solution
Add a public static method on RxState (or an extension method) that allows setting the exception handler directly:
// Option A: public setter method on RxState
RxState.SetDefaultExceptionHandler(myObserver);
// Option B: extension method on IMutableDependencyResolver
resolver.WithDefaultExceptionHandler(myObserver);The builder's WithExceptionHandler should internally call the same public API. This keeps the builder as a convenience layer, not the only path.
Files Involved
src/ReactiveUI/RxState.cs— makeInitializeExceptionHandlerpublic or add a public wrappersrc/ReactiveUI/Builder/ReactiveUIBuilder.cs— call the public API internally
Acceptance Criteria
- Users can configure
DefaultExceptionHandlerwithout usingRxAppBuilder - The builder pattern continues to work as-is
- Unit tests cover both paths
- Update website documentation (see reactiveui/website issue)
Related: #4296