Skip to content

Conversation

@BekAllaev
Copy link
Contributor

What kind of change does this PR introduce?
This PR adds a ReactiveOwningComponentBase<T> to the ReactiveUI.Blazor project, as requested in #3001.

What is the current behavior?
There is currently no reactive base component that combines OwningComponentBase<T> with ReactiveUI’s IViewFor<T> / activation support in ReactiveUI.Blazor.

What is the new behavior?
Blazor components can derive from ReactiveOwningComponentBase<T> to:

  • use an owning DI scope via OwningComponentBase<T>,
  • expose a reactive ViewModel property,
  • participate in activation (ICanActivate) and automatically call StateHasChanged on INotifyPropertyChanged changes.

What might this PR break?
No breaking changes are expected. The PR only introduces a new base class and does not modify existing public APIs or behavior.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:
Fixes #3001.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces ReactiveOwningComponentBase<T> to ReactiveUI.Blazor, providing Blazor components with ownership-based dependency injection (via OwningComponentBase<T>) combined with ReactiveUI's view model binding and activation support. This addresses issue #3001 by filling a gap in the ReactiveUI.Blazor component hierarchy where no reactive base component existed for scenarios requiring scoped service ownership.

Key Changes:

  • Adds new ReactiveOwningComponentBase<T> class that extends OwningComponentBase<T>
  • Implements IViewFor<T>, INotifyPropertyChanged, and ICanActivate interfaces
  • Provides automatic StateHasChanged calls on view model property changes
  • Includes activation/deactivation lifecycle support for IActivatableViewModel

}

/// <summary>
/// Raises the <see cref="PropertyChanged"/> event.
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML documentation summary says "Raises the event" but all other reactive Blazor component base classes use "Invokes the property changed event." This should be updated for consistency:

/// <summary>
/// Invokes the property changed event.
/// </summary>
Suggested change
/// Raises the <see cref="PropertyChanged"/> event.
/// Invokes the property changed event.

Copilot uses AI. Check for mistakes.
- Use PropertyChangedEventHandler instead of PropertyChangedEventHandler?
- Edit summary of OnPropertyChanged
@glennawatson
Copy link
Contributor

The pr comments are ai generated so like the disposed one you highlighted it could just be redundant.

@BekAllaev
Copy link
Contributor Author

Ah, got it — thanks! I’ve fixed some of them already and also made a few other changes, such as removing the _disposedValue variable.

@glennawatson glennawatson merged commit f2f9022 into reactiveui:main Nov 24, 2025
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ReactiveOwningComponent

2 participants