# destroyExistingPod method

1. @override

Future<void> destroyExistingPod(

1. Object existing,
2. Class type,
3. String name

)
override

Destroys an existing pod instance by invoking its destruction methods.

This method calls destruction callbacks such as @PreDestroy methods or DisposablePod interfaces.

## Usage Example:

    final pod = getExistingPod();
    await factory.destroyExistingPod(pod, Class<MyPod>(), 'myPod');
    // Now pod's @PreDestroy methods have been called

@param existingPod The pod instance to destroy @param type The class type of the pod @param podName The name of the pod being destroyed @return A Future that completes when destruction is done

## Implementation

    @override
    Future<void> destroyExistingPod(Object existing, Class type, String name) async {
      try {
        if(DisposableLifecycleManager.hasDestroyMethod(existing, getMergedPodDefinition(name))) {
          // Apply destruction post-processors
          for (PodDestructionProcessor processor in getPodProcessorCacheManager().destruction) {
            processor.processBeforeDestruction(existing, type, name);
          }
        }
      } catch (e) {
        if(logger.getIsWarnEnabled()) {
          logger.warn("Destruction of pod failed: $e");
        }
      }
    }