Session

public protocol Session

The Session which is responsible for performing URL Load requests

  • API to perform a request

    Declaration

    Swift

    func performRequest(_ requestProvider: URLRequestProvider) -> ResponseHandler

    Parameters

    requestProvider

    A type conforming to URLRequestProvider protocol

  • API to cleanup session resources

    The cleanup() API in the Session protocol is designed to properly release resources and prevent memory leaks when a session instance is no longer needed. It performs the following key actions:

    • Cancels all active network tasks to avoid unnecessary background operations
    • Clears the internal queue of pending requests
    • Invalidates the underlying URLSession and sets it to nil

    This API is essential because URLSession maintains strong references to its delegate (the session instance), which can create retain cycles and memory leaks if not properly cleaned up. By calling cleanup() (typically in the deinitializer), the session ensures all resources are released and no dangling references remain, improving app stability and memory management.

    Declaration

    Swift

    func cleanup()