Comments (4)
Do you need to dispose is the first reaction. Observables often do not.
from reactiveui.
Strictly speaking, probably not. .Deactivate(ignoreRefCount: true)
should force the removal of the sensitive references that could cause a memory leak if left alive.
This still seems like a violation of the class's apparent contract. And to me, there's value in Disposing the activator, in that if something DOES try to activate it again, I get an exception, and a bug in my own code is revealed.
from reactiveui.
Observables aren't honoring that contract anyway. They just adopted the IDisposable to get advantages of some of the mechanics. It's a mistake to think you have to dispose all of them. Depends on ownership of the handle.
from reactiveui.
I meant more the "contract" regarding the Activated
and Deactivated
events. That's got nothing to do with disposal mechanics.
Actually, scratch what I said earlier. ViewModelActivator.Deactivate(ignoreRefCount: true)
does not clear out all potentially sensitive references, because the two subjects for Activated
and Deactivated
could have subscribers, and the only way to clear those, currently, is through disposal.
I think an appropriate change would be from...
public void Deactivate(bool ignoreRefCount = false)
{
if (Interlocked.Decrement(ref _refCount) == 0 || ignoreRefCount)
{
Interlocked.Exchange(ref _activationHandle, Disposable.Empty).Dispose();
_deactivated.OnNext(Unit.Default);
}
}
...to...
public void Deactivate(bool ignoreRefCount = false)
{
var wasActive = ignoreRefCount
? (Interlocked.Exchange(ref _refCount, 0) != 0)
: (Interlocked.Decrement(ref _refCount) == 0);
if(wasActive)
{
Interlocked.Exchange(ref _activationHandle, Disposable.Empty).Dispose();
_deactivated.OnNext(Unit.Default);
}
}
from reactiveui.
Related Issues (20)
- [Bug]: Property observers on the same object, but with different schedulers, sometimes run on the wrong scheduler HOT 5
- [Bug]: Accessibility properties SizeOfSet and PositionOfSet are not being set when using <ReactiveWindow> HOT 6
- [Bug]: ReactiveUI incompatible with .NET Assembly Load Contexts HOT 2
- [Bug]: On Maui initial NavigateAndReset pushes the same screen twice HOT 8
- Make generic IViewFor<TViewModel> implementation optional in favor of non-generic IViewFor HOT 15
- Add overloads for the command binders that accept IViewFor HOT 1
- [Bug]: got imcompatible message when using with .net 7 HOT 2
- [Bug]: Visual Studio hot reload broken HOT 21
- [Bug]: Putting RoutedViewHost inside a TabControl on Avalonia causes an app crash after navigating the second time HOT 7
- [Bug]: `ObservableAsPropertyHelper` emits property changed for lazy initial value after first-time reading and doesn't respect `DistinctUntilChanged` HOT 1
- [Bug]: WPF ReactiveCommand stays disabled after first execution HOT 9
- [Bug]: Mark ReactiveObject IObservable properties with DisplayAttribute for Winforms HOT 9
- ReactiveUI.WPF does not include .net 8.0 as a target: HOT 3
- [Bug]: Unable to use activation of views on Windows with MAUI HOT 2
- ViewModelViewHost: Better to Allow Developers Bypass the Default Fallback Behavior That Resovles View With No Contract HOT 2
- [Bug]: WireUpControls throws exception in net8.0-android HOT 8
- [Bug]: ViewModelViewHost does not set DataContext in WPF HOT 2
- [Bug]: WPF targeting issue for net6.0-windows HOT 4
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveui.