ReferenceCounter mixin
Mixin class for DisposeHandler - mostly used with LazyControl and/or to control reference within Widget Tree. Counts references by hashCode. References must be added/removed manually.
When there is 1 or more reference then preferSoftDispose is set. Counter don't hold 'ref' to other objects, just their hashes.
- Superclass constraints
- Available extensions
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- preferSoftDispose ↔ bool
-
requestDispose will execute softDispose. Useful for items in list and objects stored in ControlFactory. Final dispose must be handled manually.
getter/setter pairinherited-setteroverride-getter
- preventDispose ↔ bool
-
requestDispose do nothing if set. Final dispose must be handled manually.
getter/setter pairinherited
- referenceCount → int
-
Number of registered references.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addReference(
Object sender) → void -
Reference is passed by given
sender
, but only Object.hashCode is store, to prevent 'shady' two way referencing (so native GC will not be affected). When there is 1 or more reference then preferSoftDispose is set. -
clearReferences(
) → void - Clears all references. So preferSoftDispose is not set.
-
dispose(
) → void -
Used to clear and dispose object.
Unsubscribe and close all sources. Prepare object for GC.
Can be called multiple times!
override
-
disposeWith(
DisposeObserver observer) → void -
Available on Disposable, provided by the DisposableExt extension
Register for dispose with givenobserver
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeReference(
Object sender) → void -
Removes reference of given
sender
. When there is 1 or more reference then preferSoftDispose is set. -
requestDispose(
[Object? sender]) → void -
Executes dispose based on preventDispose and preferSoftDispose settings.
sender
- actual object that requesting dispose - can be null.override -
softDispose(
) → void -
Just soft dispose - stop loading / subscriptions etc.
For example called when List item hides and is recycled.
Also useful when Control is used with multiple Widgets to prevent fatal dispose.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited