Skip to content

Commit 1d11336

Browse files
authored
Fix for does not trigger WhenActivated() (#3808)
<!-- 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**:
1 parent d2fd0a3 commit 1d11336

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ReactiveUI.Blazor/ReactiveInjectableComponentBase.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public void Dispose()
7070
protected override void OnInitialized()
7171
{
7272
_initSubject.OnNext(Unit.Default);
73+
if (ViewModel is IActivatableViewModel avm)
74+
{
75+
Activated.Subscribe(_ => avm.Activator.Activate()).DisposeWith(_compositeDisposable);
76+
Deactivated.Subscribe(_ => avm.Activator.Deactivate());
77+
}
78+
7379
base.OnInitialized();
7480
}
7581

@@ -132,4 +138,4 @@ protected virtual void Dispose(bool disposing)
132138
_disposedValue = true;
133139
}
134140
}
135-
}
141+
}

0 commit comments

Comments
 (0)