Skip to content

Commit

Permalink
Fix for does not trigger WhenActivated() (#3808)
Browse files Browse the repository at this point in the history
<!-- Please be sure to read the
[Contribute](https://github.com/reactiveui/reactiveui#contribute)
section of the README -->

**What kind of change does this PR introduce?**
<!-- Bug fix, feature, docs update, ... -->

Fix for #3413

**What is the current behavior?**
<!-- You can also link to an open issue here. -->

IActivatableViewModel does not activate

**What is the new behavior?**
<!-- If this is a feature change -->

adds ability to hook to IActivatableViewModel Activate and Deactivate

**What might this PR break?**

None expected

**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**:
  • Loading branch information
ChrisPulman committed May 14, 2024
1 parent d2fd0a3 commit 1d11336
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ReactiveUI.Blazor/ReactiveInjectableComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public void Dispose()
protected override void OnInitialized()
{
_initSubject.OnNext(Unit.Default);
if (ViewModel is IActivatableViewModel avm)
{
Activated.Subscribe(_ => avm.Activator.Activate()).DisposeWith(_compositeDisposable);
Deactivated.Subscribe(_ => avm.Activator.Deactivate());
}

base.OnInitialized();
}

Expand Down Expand Up @@ -132,4 +138,4 @@ protected virtual void Dispose(bool disposing)
_disposedValue = true;
}
}
}
}

0 comments on commit 1d11336

Please sign in to comment.