# registerDisposableHandler method

1. @protected

Future<void> registerDisposableHandler(

1. String name,
2. DisposablePod pod,
3. RootPodDefinition root

)

Registers a disposable handler for a pod that requires destruction callbacks.

This method sets up the appropriate destruction callback based on the pod's scope. For singleton pods, it registers a disposable pod. For scoped pods, it registers with the scope's destruction callback mechanism.

`name` the name of the pod `pod` the pod instance `root` the pod definition containing scope information

## Implementation

    @protected
    Future<void> registerDisposableHandler(String name, DisposablePod pod, RootPodDefinition root) async {
    		if (!root.scope.isPrototype && await requiresDestruction(pod, root)) {
        final handler = DisposableLifecycleManager(pod, name, root, getPodProcessorCacheManager().destruction.toList());

    			if (root.scope.isSingleton) {
    				// Register a DisposablePod implementation that performs all destruction
    				// work for the given pod: DestructionAwarePodPostProcessors,
    				// DisposablePod interface, custom destroy method.
    				registerDisposablePod(name, pod, root.type.getQualifiedName());
    			} else {
    				// A pod with a custom scope...
    				final scope = _scopes.get(root.scope.type);
    				if (scope == null) {
    					throw new IllegalStateException("No Scope registered for scope name '${root.scope.type}'");
    				}

    				scope.registerDestructionCallback(name, handler);
    			}
    		}
    	}