disposeObject static method
Disposes an object and executes all attached disposers.
Parameters:
target: The object to dispose
This method executes all disposers attached to the target object and removes them from the attachment list. After calling this method, the object's attachments are cleared.
Example:
final signal = Signal(0);
JFinalizer.attachToJoltAttachments(signal, () => subscription.cancel());
// Later, manually dispose:
JFinalizer.disposeObject(signal);
// subscription.cancel() will be called
Implementation
static void disposeObject(Object target) {
final originalDisposers = joltAttachments[target];
if (originalDisposers == null) return;
joltAttachments[target] = null;
final disposers = {...originalDisposers};
for (final disposer in disposers) {
disposer();
}
joltFinalizer.detach(originalDisposers);
disposers.clear();
}