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**:
This commit is contained in:
Родитель
d2fd0a3be8
Коммит
1d11336e09
|
@ -70,6 +70,12 @@ public class ReactiveInjectableComponentBase<T> : ComponentBase, IViewFor<T>, IN
|
|||
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();
|
||||
}
|
||||
|
||||
|
@ -132,4 +138,4 @@ public class ReactiveInjectableComponentBase<T> : ComponentBase, IViewFor<T>, IN
|
|||
_disposedValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче